In a git repository I get a git patch when invoking git diff, e.g.
diff --git a/a b/a
index 7898192..6178079 100644
--- a/a
+++ b/a
@@ -1 +1 @@
-a
+b
which can be passed to patch -p1. Is there any way to create such a patch without the condition that the diffed files are in a git repository.
git diff path1 path2 produces a patch, but it's (almost) in the same format as patches produced with diff -u. This leads to the very odd lack of manpages and tutorials to cover the usecase where the second file from which the patch was created is deleted before the application takes place. It's deleted in almost all uses because otherwise every invokation of patch could be replaced with cp (at least within the same repository). Maybe it's necessary to edit the patch - again no explanation nowhere in the world.
I'm aware that a git repository can be easily created with git init, but I'm looking for a possibility to avoid that.
git diff can be used outside a git repository as well with git diff path1 path2, but diff -u creates unified patches which can be used in a similar way.
Whereas one might think that the pathes of the output need to be adjusted based on manpages and tutorials, the question which file ought to be patched indicates a wrong -p values which is far from intuitive and should be documented.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With