Skip to content

Instantly share code, notes, and snippets.

@drubin
Last active April 24, 2017 05:48
Show Gist options
  • Save drubin/5848415 to your computer and use it in GitHub Desktop.
Save drubin/5848415 to your computer and use it in GitHub Desktop.
Useful git commands

Clean remote branches

git remote prune origin 

Clean branches already merged into master

git checkout master
for k in $(git branch -a --merged|grep -v "\->"|sed s/^..//);do echo -e $(git branch -d "$k");done

Print local branches sorted by last commited by

for k in $(git branch -a |grep -v "origin"|sed s/^..//);do echo -e $(git log -1 --pretty=format:"%Cgreen%ci %Cred%cr%Creset" "$k")\\t"$k";done|sort
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment