Skip to content

Instantly share code, notes, and snippets.

@yusefnapora
Created June 30, 2021 17:02
Show Gist options
  • Save yusefnapora/01fed85eada0e59baa57f3ca2dfa6669 to your computer and use it in GitHub Desktop.
Save yusefnapora/01fed85eada0e59baa57f3ca2dfa6669 to your computer and use it in GitHub Desktop.
git aliases to checkout the head branch of a repo
[alias]
upstream-name = !git remote | egrep -o '(upstream|origin)' | tail -1
head-branch = !basename $(git symbolic-ref refs/remotes/$(git upstream-name)/HEAD)
cm = !git checkout $(git head-branch)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment