在Git中,如何获得从一个修订版到另一个修订版的文件更改的详细列表?

在Git中,如何获得从一个修订版到另一个修订版的文件更改的详细列表?

问题描述:

我在我的服务器上使用Git存储库来版本发送到服务器的用户数据文件。我有兴趣在任何两个版本之间获得更改文件的列表。

I use a Git repository on my server to version user data files sent to the server. I'm interested in getting a list of changed files between any two revisions.

我知道 git diff --name-only< rev1&gt ; < rev2> ,但这只给我一个文件名列表。我特别对重命名和副本感兴趣。理想情况下,输出将如下所示:

I know about git diff --name-only <rev1> <rev2>, but this only gives me a list of file names. I'm especially interested in renames and copies, too. Ideally, the output would be something like this:

updated:  userData.txt
renamed:  picture.jpg -> background.jpg
copied:   song.mp3 -> song.mp3.bkp

可能吗? - name-status 也似乎不表示重命名和复制。

Is it possible? --name-status also doesn't seem to indicate renames and copies.

git diff --name-status -C <rev1> <rev2>

应该更接近您要查找的内容。

should be closer to what you are looking for.

- name-status 将显示文件名和它们各自的状态:

--name-status would display the file names and their respective status:

(A|C|D|M|R|T|U|X|B)




C),已删除(D),已修改(M),已更名(R),

类型(即常规文件,符号链接,子模块,...)已更改(T),

未合并(U),未知(X)或配对Broken(B)

Added (A), Copied (C), Deleted (D), Modified (M), Renamed (R),
type (i.e. regular file, symlink, submodule, …) changed (T),
Unmerged (U), Unknown (X), or pairing Broken (B)

OP Jean Philippe Pellet 补充道:

(to which the OP Jean Philippe Pellet adds:


状态字母 R C 之后总是跟着一个分数,表示移动源和目标之间的相似百分比或者复制,并且是唯一的那样。

The status letters R and C "are always followed by a score denoting the percentage of similarity between the source and target of the move or copy, and are the only ones to be so". )





Regarding files copied or moved:

-C[<n>]
--find-copies[=<n>]




检测副本以及重命名。如果指定 n ,它的含义与 -M 相同。



--find-copies-harder




出于性能原因,默认情况下, -C 选项仅在原始文件该副本在相同的变更集中进行了修改。

该标志使命令检查未修改的文件作为副本源的候选项。

这对于大型项目来说是非常昂贵的操作,所以谨慎使用它。给多个 -C 选项具有相同的效果。

For performance reasons, by default, -C option finds copies only if the original file of the copy was modified in the same changeset.
This flag makes the command inspect unmodified files as candidates for the source of copy.
This is a very expensive operation for large projects, so use it with caution. Giving more than one -C option has the same effect.






brauliobo 建议> a>:


brauliobo recommends in the comments:

git diff --stat -C
git show --stat -C
git log --stat -C