Omid's Blog

GIT Cheat Sheet

A small git cheat-sheet.

Upload a local folder to yourown github repo:

git init
git add -A .
git add '*.txt'
git status
git commit -m "I added everything"
git remote add origin https://github.com/try-git/try_git.git
git push origin master
#Uploads everything to github
git config --global credential.helper cache
#Saves github password for some time defined by the command below: 
git config --global credential.helper 'cache --timeout=3600'
Finnished!
To move a branch to master:
> git branch -f master branchToMoveMasterTo
>
>
>
> What this is actually doing is creating a new branch called master that points to branchToMoveMasterTo. Since we already have a branch called master, we need the -f flag to say we want to delete the original master
>
git pull -u origin master
Other commands:
git checkout -b new_branch
or
git branch new_branchgit
git checkout new_branch
git rm -r folder_ofcats   (-r is the recursive option)
git commit -am “deleted files” (auto removes deleted files with the commit).
git checkout master (go back to master branch)
git merge clean_up (merges the clean_up branch into the master)
git branch -d clen_up (deletes the cleanup branch)
if you don’t wanna commit yet, stash them. Use the command ‘<span class="highlight">git</span> stash‘ to stash your changes, and ‘<span class="highlight">git</span> stash apply‘ to re-apply your changes after your pull.
to Clone a repo:
$ <span class="highlight">git</span> clone https://github.com/schacon/grit.<span class="highlight">git</span> mygrit<br clear="none" />Just go to a folder and execute that! 


Get Git-Bash
http://git-scm.com/
< Config >
git config –system
git config –user
               –global
git config –global user.name “Omid Hezaveh”
git config –list
git config –global core.editor “gim”
git config –global core.editor “gedit -wl1”
wl1 = wait on line one
git config –global color.ui true
option autocompletion:
curl -OL https://github.com/git/git/raw/master/contrib/completion/git-completion.bash
curl -OL https://github.com/git/git/raw/master/contrib/completion/git-completion.bash
GNU nano 2.2.6 File: .bash_profile Modified
nano .bash_profile
if [ -f ~/.git-completion.bash ]; thensource ~/.git-completion.bash fi

git help
git help command
—————
in the project directory of choice:
git init
———-
git add .
it adds all the new files to git
git commit -m “initial commit kardam”
init > add > commit

git log -n 3
just shows last 3 commits data
git log –since=2012-06-15
git log –grep=”init”

git status
the interactive course
(http://gik.fi/quickgik)
Posted October 26, 2014

Omid Hezaveh lives and works in Helsinki find him on twitter