Skip to content

Instantly share code, notes, and snippets.

@oxpayken
Forked from airdrummingfool/nth-commit.sh
Last active August 29, 2015 14:27
Show Gist options
  • Save oxpayken/f428b59c48d93c2d624f to your computer and use it in GitHub Desktop.
Save oxpayken/f428b59c48d93c2d624f to your computer and use it in GitHub Desktop.
Checkout the nth commit on a specified branch.
#!/bin/bash
# nth-commit.sh
# Usage: `nth-commit.sh n [branch]`
branch=${2:-'master'}
SHA1=$(git rev-list $branch | tail -n $1 | head -n 1)
git checkout $SHA1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment