Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
423 views
in Technique[技术] by (71.8m points)

rename - In Git, how do I get a detailed list of file changes from one revision to another?

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.

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

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
git diff --name-status -C <rev1> <rev2>

should be closer to what you are looking for.

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

(A|C|D|M|R|T|U|X|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)

(to which the OP Jean Philippe Pellet adds:

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>]

Detect copies as well as renames. If n is specified, it has the same meaning as for -M<n>.

--find-copies-harder

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 recommends in the comments:

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

56.8k users

...