Git cheatsheet

tags: git 

Various things I need to remember for Git, but that I don’t remember. I know I can read the help to get this, but I still have to wade through a bunch of verbiage.

Undo the last commit (--soft keeps changes):

git reset --soft HEAD~1
git reset --hard HEAD~1

Delete remote branches (Stackoverflow):

git push all --delete <branch-name>

git remote prune origin

Show filenames in log messages (Stackoverflow)

git log --name-only

Show all merged branches

git branch --merged master

See which .gitignore rules exclude a file (Stackoverflow)

git check-ignore -v **/*

Find the commit that deleted a file (git docs) (Stackoverflow)

git rev-list -n 1 HEAD -- <file_path>