Background
Given the following files in tree (Commit F)
文件A:
a
文件B:
b
名录结构:
.
├── a
└── b
Swap the names of the two files (Commit F -> G)
之后,他们打着G号:
# on commit F
git mv a c
git mv b a
git mv c a
git commit -m "G"
www.un.org/Depts/DGACM/index_spanish.htm
git diff HEAD^
产出:
diff --git a/a b/a
index 7898192..6178079 100644
--- a/a
+++ b/a
@@ -1 +1 @@
-a
+b
diff --git a/b b/b
index 6178079..7898192 100644
--- a/b
+++ b/b
@@ -1 +1 @@
-b
+a
鉴于内容没有改变,我期望能够发现这一点。 我可以发现,在单页中,女方是谁,这就解释了为什么这只是为了姓名交换而发生的。
Rename the files without reusing existing names (Commit F -> H)
# on commit F
git mv a c
git mv b d
git commit -m "H"
www.un.org/Depts/DGACM/index_spanish.htm
git diff HEAD^
产出:
diff --git a/a b/c
similarity index 100%
rename from a
rename to c
diff --git a/b b/d
similarity index 100%
rename from b
rename to d
Question
www.un.org/Depts/DGACM/index_spanish.htm 当新名字do not与树中已经填满的档案名称相勾结时,如何发现更名的树冠,但not在新名字<docolide?上发现更名的人。
补充问题: 我怎么能够发现各名录之间的内容变化(例如,git diff-no-index dir1 dir2
),在档案经常有名字时完全忽略档案名称? 首先,我认为,这一使用案例完全适合git,但我猜测它不是......(Can git改称对已经存在的档案进行探测?)。
EDIT:
I see a common theme in comments about git
not tracking file renames or other filesystem metadata in commits. I m aware of this, and this doesn t answer the question I ve posted on why git behaves differently when generating a diff if names are reused versus when names are unique:
考虑(除重纸外,没有承诺):
名录结构:
1
├── a
└── b
2
├── a
└── b
1/a:
a
文件1/b:
b
File 2/a:
b
文件2/b:
a
内容没有改变,因此,iff应该空白(或显示更名):
git diff --no-index 1 2
产出(但并非):
diff --git a/1/a b/2/a
index 7898192..6178079 100644
--- a/1/a
+++ b/2/a
@@ -1 +1 @@
-a
+b
diff --git a/1/b b/2/b
index 6178079..7898192 100644
--- a/1/b
+++ b/2/b
@@ -1 +1 @@
-b
+a
然而,如果名录结构类似:
1
├── a
└── b
2
├── c
└── d
文件2/c:
a
文件2/d:
b
监察员只显示:
git diff --no-index 1 2
产出:
diff --git a/1/b b/2/c
similarity index 100%
rename from 1/b
rename to 2/c
diff --git a/1/a b/2/d
similarity index 100%
rename from 1/a
rename to 2/d