Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 668
CuriousMind Avatar asked Apr 15 '12 00:04

CuriousMind


People also ask

How do you squash commits in one?

In case you are using the Tower Git client, using Interactive Rebase to squash some commits is very simple: just select the commits you want to combine, right-click any of them, and select the "Squash Revisions..." option from the contextual menu.

How do you squash all commits in a branch?

Git's squash commits command There is no explicit Git squash command. Instead, to squash git commits, the interactive git rebase is used. To squash all commits on a single branch, the interactive git rebase command must be passed one of two arguments: the id of the commit from which the branch split from its parent.


1 Answers

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

like image 166
Yogesh Avatar answered Oct 01 '22 23:10

Yogesh