Git create full file patches to download/distribute?
Either i'm going nuts or nobody likes/liked this feature, but a long time ag开发者_如何转开发o 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.
It seems that I misunderstood what you wanted in my other answer. git archive
can take a list of paths to include in the archive, so you could do:
git archive -o /tmp/foo.zip HEAD $(git diff --name-only oldcommit HEAD)
If your filenames contain surprising characters, though, it would be safer to do:
git diff -z --name-only oldcommit HEAD | xargs -0 git archive HEAD -o /tmp/blah.zip --
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?
精彩评论