Skip to content

Instantly share code, notes, and snippets.

@lloiacono
Created January 14, 2016 09:27
Show Gist options
  • Save lloiacono/ec8358708ef93adee7fd to your computer and use it in GitHub Desktop.
Save lloiacono/ec8358708ef93adee7fd to your computer and use it in GitHub Desktop.
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