Frage

I export one diff file, use 'git diff HEAD^ HEAD > a.diff' . So, I wanna use a.diff file patch to another source code. I use command 'patch -p0 < a.diff', but it not works. said, "can't find files." So, my question is: how to path a.diff file to source code? Can someone help me solving this quesiont? thanks a lot.

War es hilfreich?

Lösung

With git the diff output requires removing up to the first / in the path. This should work:

patch -p1 < a.diff

Also try using git format-patch and git am (preserves logs if applying patch in another git directory):

rm -rf *.patch
git format-patch -1
git am *.patch
rm -rf *.patch
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top