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
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'
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
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<span class="highlight">git</span> mygrit<br clear="none" />Just go to a folder and execute that! 

Get Git-Bash
< Config >
git config –system
git config –user
git config –global “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
curl -OL
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
Posted October 26, 2014

Omid Hezaveh lives and works in Helsinki find him on twitter