Skip to content

Commit

Permalink
Clean up your git: add comments to commands
Browse files Browse the repository at this point in the history
And add the git prune origin command cause it's needed if remote
branches have been deleted.
  • Loading branch information
danielbeardsley committed Apr 22, 2013
1 parent 010f51b commit ebf6de8
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions _posts/2012-04-26-clean-up-your-git.md
Expand Up @@ -19,17 +19,20 @@ to do something that can be done in a one line bash command?
Delete local merged branches
----------------------------
{% highlight bash %}
git branch --merged master |
grep -v master |
xargs git branch -d
git branch --merged master | # list branches merged into master
grep -v master | # exclude master
xargs git branch -d # tell git to delete them
{% endhighlight %}

Delete branches on your origin
------------------------------
{% highlight bash %}
git branch -r --merged origin/master |
grep -v master |
grep "origin/" |
sed "s| origin/|:|" |
xargs git push origin
git remote prune origin # prune deleted tracking branches
git branch -r --merged origin/master | # list branches merged into master
grep -v master | # exclude master
sed -n "s| origin/|:|p" | # use remote branch delete syntax
# and only include origin branches
xargs git push origin # delete them on the remote
{% endhighlight %}


0 comments on commit ebf6de8

Please sign in to comment.