Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How do I merge a large number of commits in phases of, say, 20 commits at a time?

share|improve this question
up vote 2 down vote accepted

git merge accepts any commit specification, so you can do:

git merge ...
git merge origin/master~60
git merge origin/master~40
git merge origin/master~20
git merge origin/master

or even git merge 357a887 to merge everything up to commit 357a887...

share|improve this answer

Why would you want to do that? Mashing up the commits just gets rid of the history.

If you really do want to do this, I'd go for "git rebase -i" (interactive rebase), that alows you to go wild rewriting history (reordering commits, smashing them together, delete some, ...). Splitting commits can be done, but it is a bit tricky.

I'd go like:

git branch save # don't want to lose the original accidentally...

git rebase -i HEAD~20 # for last 20 commits

# Edit the offered template at will, minimal help included

# Exiting the editor makes git do as told, it might stop if manual intervention required

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .