Nikola Kotur
Nikola Kotur

Reputation: 1994

Can git format patch so it can be used with patch program?

I'd need to create simple patches from git repository that can be applied with plain simple patch command line utility.

Can it be done?

Upvotes: 19

Views: 4092

Answers (2)

xolox
xolox

Reputation: 5114

The accepted answer states the following:

Patches, that git diff yields, are correctly processed by patch tool.

I'm pretty sure I just ran into a case where this is incorrect. /usr/bin/patch just silently (without reporting an error) ignored my patch including file rename information, thereby breaking a deployment (fortunately I'm only testing the deployment at the moment :-) ...

I'm posting this alternative answer as a heads up for other people running into the same problem because I was scratching my head for a while... Also comments to answers on StackOverflow apparently can't contain quotes.

Ironically enough I just now switched to the unified diff format to overcome this problem and now my deployment breaks in a different way because unified diffs can't represent the creation of empty files (e.g. __init__.py). Talk about being between a rock and a hard place!

Upvotes: 4

P Shved
P Shved

Reputation: 99254

Patches, that git diff yields, are correctly processed by patch tool.

patch skips all the additional info git appends to the patch file. To apply the patch you most likely will need -p1 option.

Upvotes: 21

Related Questions