git commit 消息将文件显示为“已复制”而不是“已修改”。有什么影响?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2673431/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 04:14:41  来源:igfitidea点击:

git commit message showing file as 'copied' instead of 'modified'. What are the implications?

git

提问by Justin

strong textgit status shows file as modified, however when commiting it shows the file as been copiedie:

strong textgit status 将文件显示为已修改,但是在提交时它显示文件已被复制,即:

git status
modified: foo/bar/baz.xml

git status
修改:foo/bar/baz.xml

git commit
copied: bar/foo/baz.xml -> foo/bar/baz.xml

git commit
复制:bar/foo/baz.xml -> foo/bar/baz.xml

Why is it showing this file as copied if it was not. The two files were identical before the change.

如果不是,为什么它显示此文件为已复制。这两个文件在更改前是相同的。

回答by knittl

git tracks content, not files. if two files are the same (or very much the same) git recognizes them as copied. there shouldn't be any implications from this

git 跟踪内容,而不是文件。如果两个文件相同(或非常相同),git 会将它们识别为已复制。这不应该有任何影响

in your case both files were identical (100 %), so git has no possibility to know if the file was copied, or just accidentally happened to be the same.

在你的情况下,这两个文件是相同的(100%),所以 git 不可能知道文件是否被复制,或者只是偶然碰巧相同。

don't worry, git only stores snapshots of the tree to the repository. you can control copy and rename detection for git logwith parameters -Cand -M, git will then try harder to find renames/copies

别担心,git 只将树的快照存储到存储库中。你可以控制复制和重命名检测git log与参数-C-M,然后git会更加努力找到重命名/份