💾 Archived View for xoc3.io › blog › 2021-05-17 captured on 2021-12-06 at 14:29:53. Gemini links have been rewritten to link to archived content
⬅️ Previous capture (2021-11-30)
-=-=-=-=-=-=-
for work today i had to make identical changes to 2 separate branches. the problem is that one branch moved all the files i was changing to a different directory. i knew this could be solved with the patch command, but i didn't know exactly how. now i know how.
one think i learned is that the `git diff` format is the same format as `diff`, so it works with the patch command. i guess that should be common sense, but it wasn't something i actually knew for certain before. the next thing i learned was about the patch command, specifically the `-l` and `-p` options. `-p` lets you pass a number that will remove leading directories specified in the patch file. git diff always puts a leading `a/` and `b/` directory on the diff, so i needed to pass a `-p1`. the `-l` command ignores whitespace. i thought `-l` would take care of carriage returns too, but it didn't, so i had to pipe the git diff output through `dos2usix` too.
the end result is something that looked like this:
git diff <commit-1> <commit-2> | dos2unix | patch -lp1
yep. that's what i learned today.