###################### ### GIT CheatSheet ### ###################### #################################################################################################### ### FETCHING ####################################################################################### #################################################################################################### git fetch git fetch -a/--all #################################################################################################### ### BRANCHES ####################################################################################### #################################################################################################### ### list git branch git branch -a/--all git branch -r/--remote git branch --merged git branch --no-merged git branch --merged master ### rename ### 1) local - on it git branch -m new-name ### 2) local - on different git branch -m old-name new-name ### 3) remote - delete old-name remote and push new-name local git push origin :old-name new-name git push origin -u new-name ### delete ### 1) local git branch -d/--delete BRANCH git branch -D/--delete --force BRANCH ### 2) remote git push --delete origin BRANCH #################################################################################################### ### CHECKOUT ####################################################################################### #################################################################################################### git checkout BRANCH git checkgout -b BRANCH git checkgout -b BRANCH origin/BRANCH #################################################################################################### ### REBASE ######################################################################################### #################################################################################################### ### branch rebase ### 1) one-liner git pull --rebase origin master ### 2) old-way git fetch origin # Updates origin/master git rebase origin/master # Rebases current branch onto origin/master ### commits manipulation git rebase -i HEAD~X (X = commits behind) #################################################################################################### ### DIFF ########################################################################################### #################################################################################################### #################################################################################################### ### STASHING ####################################################################################### #################################################################################################### git stash show git stash show -p/--patch git stash push -m MESSAGE PATH git stash pop stash@{X} (X = stash number) #################################################################################################### ### SETTING UPSTREAM ############################################################################### #################################################################################################### git branch --set-upstream-to=origin/REMOTE_BRANCH LOCAL_BRANCH #################################################################################################### #### UPDATING LOCAL FROM MASTER #################################################################### #################################################################################################### ### 1) merge git checkout BRANCH git merge origin/master git push origin BRANCH ### 2) rebase git fetch git rebase origin/master #################################################################################################### ### HISTORY ######################################################################################## #################################################################################################### git log --pretty=format:"%h %s" --graph