Skip to content

Instantly share code, notes, and snippets.

@chanwit
Created July 9, 2015 08:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chanwit/63a67063f90080c46c6d to your computer and use it in GitHub Desktop.
Save chanwit/63a67063f90080c46c6d to your computer and use it in GitHub Desktop.
# checkout prev (older) revision
git_prev() {
git checkout HEAD~
}
# checkout next (newer) commit
git_next() {
BRANCH=`git show-ref | grep $(git show-ref -s -- HEAD) | sed 's|.*/\(.*\)|\1|' | grep -v HEAD | sort | uniq`
HASH=`git rev-parse $BRANCH`
PREV=`git rev-list --topo-order HEAD..$HASH | tail -1`
git checkout $PREV
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment