Skip to content


Useful Tricks

Get the commit hash of the first commit

git rev-list HEAD | tail -n 1

Get the commit hash of the latest commit

git rev-list HEAD | head -n 1

Check, which branches contain a given commit hash

This is very useful, if you obtain the hash (e.g. from a status log), but you are not sure which branch(es) this commit belongs to.

git branch --contains COMMIT_HASH

List all local branches, which have already been merged to master

This is useful for cleaning up your local branches

git branch --merged | grep -v master