English 中文(简体)
g 更名为在档案中披露姓名
原标题:git rename detection when files swap names
  • 时间:2024-03-06 02:08:29
  •  标签:
  • git

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
问题回答

(我将评论,但我的声誉不够)

我同意第一项意见,即git主要涉及档案内容,而不是档案系统的内容。

专门小组可以做一些比较元数据的工作,例如档案处理表数据、档案制造时间以及(或)档案编辑时间,但元数据以及导致更新元数据的情况是具体实施档案系统的。 这种具体实施将造成预期行为与其他执行不同的不一致,因此,与确保新的更名的探测职能不会造成新的未预见的不一致现象的额外时间相比,不大可能制定和维持这些更名的探测行为。

记录贵国档案库历史的一种方式是,如果重要的话,将档案改名为档案,做一件事,然后将案卷改成案(将案卷选定为更重要的案卷,以跟踪),然后将案卷改名为C。

这将使后者与第二项承诺相比更为明显,而另一项承诺则从两项非依附承诺中不那么明显。

A. 预估的是,如果你重新使用高度自动化的发展工具来创造新的发展工作,被认为与档案组织历史更加一致,那么这种检验可能低于多个档案系统对多重优惠执行的兼容性。 我进一步猜测,这种事情不一定会使转轨源代码项目复杂化。

<>部分回答

回答补充问题: 我怎么能够发现各名录之间的内容变化(例如,电离层——无-指数 dir1 dir2),完全无视档案名称,因为档案往往有名字被转换?

• 编辑档案名称,以便档案中无1个编造者的姓名:

cd dir1
# probably want to do some better random or maybe just sequential id
# to ensure names don t collide
for f in *.ext; do mv -n "$f" "${f/*/$RANDOM-$RANDOM.ext}"; done

cd ../dir2
for f in *.ext; do mv -n "$f" "${f/*/$RANDOM-$RANDOM.ext}"; done

如果植根于树,则这种退学。

Then git diff --no-index dir1 dir2 will show only changed content essentially ignoring file names (identical files will show as renames).

如果可以将更名人排除在副手的产出之外,那么情况会更好。 但至少采用这种办法,我可以迅速检查是否有任何实际增加或删除(从+/-开始的路线)





相关问题
git confusion - cloning a repo is returning a past version

Im having some confusion with my git usage. I cloned a repo from one comp to the other, and the new clone is the state of the original that was active some time ago. So its cloning a past version. ...

Appropriate strategy for tagging and hotfixing with git

I was wondering if the strategy I m using for tagging and hotfixing tags (which then I use for deploying rails applications) with git is appropriate. For tagging I just tag a commit of the master ...

Tips on upgrading CVS to git/hg?

We still use CVS, I use git and hg for my personal use though I m still a novice at both, but I realize they re much more modern and better, faster, distributed, etc. It s just everyone is so ...

Using Git in a TFS shop

Using Git at home has spoiled me - I now find using TFS at work to be a bit of a drag and want to explore the possibility of using Git locally and syncing somehow with TFS. I figure there are a few ...