Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I flatten merges into a linear history?

Tags:

git

I've just sync'd my git repo and ran into a regression. I'd like to just step through the history until I find the commit to blame, but there's been a huge merge which just shows up as a single commit when I do git log.

Is there any way I can flatten this merge in my local branch so git log just has a linear history I can walk through?

like image 442
Chris Avatar asked Feb 06 '12 18:02

Chris


1 Answers

What you're looking for is interactive rebase.

You can rebase against master via git rebase -i master. You should see something like

pick ba6b4b7 Commit messages here
pick 744ea3b Another commit message
pick 33539d5 Commits all around!

You can then change the "pick"s after the first one to "squash". This will squash them all in to the top commit. You can also change the top "pick" to "fixup" to change its commit message.

like image 193
Jim Mitchener Avatar answered Oct 16 '22 16:10

Jim Mitchener