2 ms·
Oh that’s clever, I’ll try that out. Looks like you could just do a git diff > file.patch. Neat.
by barbazoo 1y ago
Oh that’s clever, I’ll try that out. Looks like you could just do a git diff > file.patch.
Neat.
- johnrob 1y agoYou’ll also want to familiarize with “git apply -3 <file name>”, for when a diff can’t be applied cleanly. It will try “harder” to merge (three way method) and if it still fails it invokes the conflict merge “UX”: <<<<<<<<< ========= >>>>>>>>>
- smcameron 1y agoThere's also Neil Brown's "wiggle" program for applying patches that don't apply. https://github.com/neilbrown/wiggle https://github.com/neilbrown/wiggle although on debian based systems I think you can just "apt install wiggle"
- johnisgood 1y agoWhat does "applying patches that don't apply" mean exactly? I know about wiggle, but I have not used it, to be honest.
- smcameron 1y agoIt means that if you do "patch -p1 --dry-run < some.patch", and it complains that it doesn't apply, wiggle can sometimes apply it anyway, and also, if you do "patch -p1 < some.patch", and it partially applies but with rejected hunks, wiggle can try to apply the rejected hunks.
- johannes1234321 1y agogit diff an pipe works, but committing and then `git format-patch` can export multiple patches and then includes metadata (commit message, date, author, etc.) which can make reasoning about such files a lot easier. In a plain diff you only got filename as metadata.