Skip to content

Instantly share code, notes, and snippets.

@oldratlee
Last active July 24, 2017 05:42
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 oldratlee/519eeddc22bd2724629225d44beb1adb to your computer and use it in GitHub Desktop.
Save oldratlee/519eeddc22bd2724629225d44beb1adb to your computer and use it in GitHub Desktop.
checkout most recent modified branch
gcor() {
# http://stackoverflow.com/questions/5188320/how-can-i-get-a-list-of-git-branches-ordered-by-most-recent-commit
# --sort=-committerdate : sort branch by commit date in descending order
# --sort=committerdate : sort branch by commit date in ascending order
git branch -a --sort=committerdate "$@" |
awk -F'remotes/origin/' '/remotes\/origin\//{print $2}' |
tail -1 |
xargs git checkout
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment