I am trying to correctly create and apply patches using Git:
- I created a new git project with two files:
first.txtandsecond.txt - I create a branch
- In this new branch, I modify the contents of both files and commit
- I move the file
second.txtto folder\second_moved.txtandfolder\second_moved.txt
Now I am creating a patch using git format-patch master --stdout > changes.patch.
Here is the content changes.patch:
From cb2a85ff9a0bc36d4f04fbe72068ae9ec3a9bcb0 Mon Sep 17 00:00:00 2001
From:
Date: Mon, 29 Sep 2014 20:46:18 -0400
Subject: [PATCH 1/2] changes
fist.txt | 2 +-
second.txt | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff
index d4b4f36..b5d9ba4 100644
+++ b/fist.txt
@@ -1 +1 @@
-first file
\ No newline at end of file
+first file foobar
\ No newline at end of file
diff
index 0f8bbfe..54e687e 100644
+++ b/second.txt
@@ -1 +1 @@
-second file
\ No newline at end of file
+second file barfoo
\ No newline at end of file
1.8.4.msysgit.0
From 09c868828cf30fba36ba04cbd476dfcb0f68f79c Mon Sep 17 00:00:00 2001
From:
Date: Mon, 29 Sep 2014 20:47:15 -0400
Subject: [PATCH 2/2] moved
folder/second_moved.txt | 1 +
second.txt | 1 -
2 files changed, 1 insertion(+), 1 deletion(-)
create mode 100644 folder/second_moved.txt
delete mode 100644 second.txt
diff
new file mode 100644
index 0000000..54e687e
+++ b/folder/second_moved.txt
@@ -0,0 +1 @@
+second file barfoo
\ No newline at end of file
diff
deleted file mode 100644
index 54e687e..0000000
+++ /dev/null
@@ -1 +0,0 @@
-second file barfoo
\ No newline at end of file
1.8.4.msysgit.0
Now I return to my main branch and apply the patch with git apply changes.patch. There is no mistake.
Here is the result of the state git status:
no changes added to commit (use "git add" and/or "git commit -a")
, second.txt. , , , folder. folder second_moved.txt. git apply.
git , , , , . ?