Skip to content

Instantly share code, notes, and snippets.

@mtib
Created January 14, 2025 12:19
Show Gist options
  • Save mtib/6699e0d27fd0a40db9fa7ceca25eaadc to your computer and use it in GitHub Desktop.
Save mtib/6699e0d27fd0a40db9fa7ceca25eaadc to your computer and use it in GitHub Desktop.
git branch list
# stolen from https://stackoverflow.com/a/2514279
function git-branches() {
for k in $(git branch | sed s/^..//); do echo -e $(git log --color=always -1 --pretty=format:"%Cgreen%ci %Cblue%cr%Creset" $k --)\\t"$k";done | sort
}
function git-remote-branches() {
for k in $(git branch -r | perl -pe 's/^..(.*?)( ->.*)?$/\1/'); do echo -e $(git show --pretty=format:"%Cgreen%ci %Cblue%cr%Creset" $k -- | head -n 1)\\t$k; done | sort
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment