Git apply does not create new files?

I am trying to create a patch diffand apply. My patch has a new file, and after applyI get an error.

git diff master origin/master > patch1.diff
git apply patch1.diff -v

Checking patch test3...
error: test3: No such file or directory

Patch:

diff --git a/test3 b/test3
deleted file mode 100644
index df6b0d2..0000000
--- a/test3
+++ /dev/null
@@ -1 +0,0 @@
-test3

What am I doing wrong or git applynot creating new files?

+5
source share
1 answer

You create your patch back - this patch is trying to delete this file. I think you would like:

git diff origin/master master > patch1.diff

You may find git format-patch. If you have master, you can do this:

git format-patch origin/master

This command will give a bunch of patch files, one for each commit that differs between your branch and origin/master. You can then apply them with git amand save all additional data, such as a commit message and information about the author.

+8
source

All Articles