git log与--follow和一起使用--patch,它将显示带有从/重命名为输出的日志。并且不要忘记--文件路径之前的。
git log --follow --patch -- path/to/file.ext
例如testdir/more-testing.txt,我系统上的文件历史记录显示:
Date: Wed Mar 18 14:48:07 2020 -0700
renamed file
diff --git a/testdir/testing.txt b/testdir/more-testing.txt
similarity index 100%
rename from testdir/testing.txt
rename to testdir/more-testing.txt
commit feb58d3ab8e8ce940f80499df0c46e8fc8caf679
Author: Igal <redacted>
Date: Wed Mar 18 14:47:18 2020 -0700
moved test.txt to subdirectory and renamed
diff --git a/test.txt b/testdir/testing.txt
similarity index 100%
rename from test.txt
rename to testdir/testing.txt
commit 34c4a7cebaeb0df5afb950972d69adea6b1a7560
Author: Igal <redacted>
Date: Wed Mar 18 14:45:58 2020 -0700
added test.txt
diff --git a/test.txt b/test.txt
new file mode 100644
index 000000000..0527e6bd2
--- /dev/null
+++ b/test.txt
@@ -0,0 +1 @@
+This is a test
(END)