tags:

views:

104

answers:

2

I would like to create a patch for the last 2 revisions.

git format-patch -2

gives me 2 patch files, one for each revision

git format-patch HEAD~2..HEAD

gives the same thing.

git format-patch -1 HEAD~2..HEAD

gives a single file, but only contains changes for the last revision.

Is there any way to do this in git?

+6  A: 
git diff HEAD~2..HEAD > my-patch.diff

It won't have any of format-patch's per-commit metadata, though.

Tobu
Obviously. What author should it have if those two commits have different authors? How should the commit message for 2-commit change look like? Etc.
Jakub Narębski
A: 

You could do something like:

$ git checkout -b tmp
$ git reset HEAD~2
$ git commit -a

The commit to branch tmp will be the same as the 2 individual commits.

William Pursell
or `git rebase -i HEAD~2`, and squash.
Tobu