Skip to content

Instantly share code, notes, and snippets.

@josephgrossberg
Created July 27, 2017 00:36
Show Gist options
  • Save josephgrossberg/62d8bf233a47b9c5c0785b35213d98fd to your computer and use it in GitHub Desktop.
Save josephgrossberg/62d8bf233a47b9c5c0785b35213d98fd to your computer and use it in GitHub Desktop.
git revision commands
# Found at: https://blog.scottnonnenberg.com/better-git-configuration/
# Check out a branch
git checkout branchname
# Check out a remote branch
git checkout remotes/origin/branchname
# Check out a specific commit
git checkout 158e4ef8409a7f115250309e1234567a44341404
# Check out most recent commit for current branch
git checkout HEAD
# ^ means 'first parent commit,' therefore the second-most recent commit in the master branch
git checkout master^
# If it's a merge commit, with more than one parent, this gets the second parent
git checkout master^2
# Same thing as three ^ characters - three 'first-parent' steps up the tree
git checkout master~3
# The first commit prior to a day ago
git checkout master@{yesterday}
# The first commit prior to 5 minutes ago
git checkout master@{5.minutes.ago}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment