Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git create full file patches to download/distribute?

Tags:

git

Either i'm going nuts or nobody likes/liked this feature, but a long time ago i used to use subversion with sourceforge system. I had the ability to create full file patches for commits done.

I cannot figure out anyway to create these in git, all i want is the files that were changed from XX commit and only those files in their entirety so that i could hand them off to someone/upload just those files to a location.

As it currently stands i'm stuck reuploading the entire project because i have nothing that tells me what was changed. Since we're also on a shared web host there is no way to get git on the server without upgrading to more expensive package.

I've tried

git archive --output=/home/username/temp.zip <commit id>

which put everything into a zip nicely but it did just that, it put everything. Also tried a variation of format-patch but that didn't seem to work.

like image 875
iarp Avatar asked Feb 11 '11 05:02

iarp


People also ask

How do I create a patch format in git?

In order to create Git patch file for a specific commit, use the “git format-patch” command with the “-1” option and the commit SHA. In order to get the commit SHA, you have to use the “git log” command and look for the corresponding commit SHA.

How do I create a patch between two commits?

You can squash those commits into one commit using git rebase . After you have that one commit, you can use git format-patch to create the patch file of it.


1 Answers

The first thing to try would be to save the output of git diff, which might be sufficient in your situation:

git diff oldcommit > test.patch

If you have changed binary files since then, you could try:

git diff --binary oldcommit > test-with-binaries.patch

In that case you'd then need to apply the patch with git apply. Otherwise, I would create a new branch based on oldcommit, do a squashed merge from master, commit the result and and use git format-patch to produce the patch. That method (and several other solutions to your problem) are described in more detail in the answers to this similar stackoverflow question: How do you squash commits into one patch with git format-patch?

like image 80
Mark Longair Avatar answered Sep 20 '22 21:09

Mark Longair