GIT – Command Line Cheat Sheet

This is my personal brain dump of common git commands that I forget from time to time. I will continue to add to this list as I come across commands that I need to lookup.

Checkout with remote tracking

git checkout -t origin/<branch name>

Squash Commits

git rebase -i HEAD~<number of commits to squash>

Find missing commits

Reference logs, or “reflogs”, record when the tips of branches and other references were updated in the local repository. Reflogs are useful in various Git commands, to specify the old value of a reference. For example, HEAD@{2} means “where HEAD used to be two moves ago”, master@{one.week.ago} means “where master used to point to one week ago in this local repository”, and so on. See gitrevisions[7] for more details.

git reflog

Leave a Reply

Your email address will not be published. Required fields are marked *