Given a git repository with the following file structure:
<repo root>
foo
example.md
I have committed example.md
with the contents Hello world
. If I navigate to the foo
directory and make a change to example.md
, I can generate a relative diff with git diff --relative > d.diff
with the contents:
diff --git a/example.md b/example.md
index 802992c..fb5067b 100644
--- a/example.md
+++ b/example.md
@@ -1 +1 @@
-Hello world
+Hello again
If I now checkout example.md
to undo the change, then try to apply the diff with git apply d.diff
(still in the foo
directory), the command exits silently and no changes are applied. How can I apply this relative diff, or generate a relative diff in such a way that it can be applied?