Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In git, how do I create a single patch for the last 2+ revisions?

Tags:

git

patch

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?

like image 256
Matthew Avatar asked Feb 07 '10 17:02

Matthew


2 Answers

git diff HEAD~2..HEAD > my-patch.diff 

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

like image 62
Tobu Avatar answered Sep 21 '22 15:09

Tobu


Use the --stdout option and then cat it to a file.

Like so:

git format-patch HEAD~2..HEAD --stdout > changes.patch 

This will keep the per-commit metadata.

like image 36
JC Brand Avatar answered Sep 21 '22 15:09

JC Brand