Skip to content

Instantly share code, notes, and snippets.

@mtib
Created January 14, 2025 12:19
Show Gist options
  • Select an option

  • Save mtib/6699e0d27fd0a40db9fa7ceca25eaadc to your computer and use it in GitHub Desktop.

Select an option

Save mtib/6699e0d27fd0a40db9fa7ceca25eaadc to your computer and use it in GitHub Desktop.

Revisions

  1. mtib created this gist Jan 14, 2025.
    8 changes: 8 additions & 0 deletions git-branches.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,8 @@
    # 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
    }