git Command Cheatsheet

Mon Nov 09 2015

Clean working copy

$ git clean -df
$ git checkout -- .

Temporarily stashing changes before pulling

$ git stash 
$ git pull
$ git stash pop

Pull from master branch

git checkout stage
git fetch origin
git merge origin/master

Find all branches that are merged

git branch --merged

Find all remote branches that are merged

git branch -r --merged > branches.txt

Delete a local branch

git branch -d [branch-name]

Delete a remote branch

git branch -rd [branch-name]
git push origin :[branch-name]

Cancel a merge

git reset --hard HEAD