views:

36

answers:

3

I like to commit locally at every opportunity - ending up with all sorts of comment spam in my git repository. Changes may get reverted multiple times, never mind that late night commits contain interesting expletives. Is there an easy way to filter my git push to a public repository to remove all of the comment spam?

Ideally, I would like each push to the public repository to collapse all of the changes in my branch into one batch, and have one, clean, comment attached to it. Is this something I can do with git, and if so, how?

A: 

Use git rebase to squash the commits into commit prior to push.

zevra0
A: 

You probably want to use git rebase -i to squash commits and edit the messages.

http://www.kernel.org/pub/software/scm/git/docs/git-rebase.html

grossvogel
+3  A: 

git rebase --interactive will let you squash, edit, split and delete commits, it's a very powerful command (risky too). Since git rebase is a history rewriting command, beware of using it on branches that were either push/pulled.

Keep in mind though that it's considered good practice to split your changes over several commits, rather than one gigantic commit.

Idan K
Idan is right on, but just to re-iterate: don't run rebase with any commits that have been made public to anyone else. If ALL commits in the rebase are on your local box, then you won't run into trouble. If one of the commits in the rebase has been pushed you will have lots of trouble.
Bryce