CuriousMind
CuriousMind

Reputation: 15798

git: how to "consolidate" the local commits

I like to commit quite frequently (and even randomly) when I am working on some code, because if I screw up somewhere I can always roll back my changes.

However, when I decide to push all the changes to the master repository, I don't like people to see all the random commits, because some of them are really meaningless to them, and it makes the change tree unnecessarily long.

How do I "consolidate" all my local commits before I push?

Upvotes: 8

Views: 2262

Answers (3)

Abe Voelker
Abe Voelker

Reputation: 31574

Do an interactive rebase, which will let you reorder, squash and edit commits to your heart's content before pushing.

Upvotes: 2

Yogesh
Yogesh

Reputation: 1335

You can combine your commits by rebase and squashing the ones you dont need.

Refere this: http://gitready.com/advanced/2009/02/10/squashing-commits-with-rebase.html

Upvotes: 5

Kit Ho
Kit Ho

Reputation: 26968

git rebase -i

An interactive editor will be prompted out.

Change all commit you want to consolidate to "squash"

Quit the editor

Upvotes: 2

Related Questions