Flatten commits on a branch

I would recommend learning to use the interactive rebase, but in case it seems too complicated to you, you can simply use

git reset --soft <diverging-commit>

to undo all commits up to the diverging point without changing the index, and

git commit -s

to make a single commit of all the changes.


Use interactive rebasing. Find the commit where your branch diverged from master (may using git merge-base; let's call the commit <diverge>), then

git rebase -i <diverge>

and an editor will pop up, allowing you to rewrite history interactively. You'll want to squash commits.

Tags:

Git