是的,我可以借助下一个命令来做到这一点:
$ git log -p -M
commit 9841f31f283c74ec9e2a33869590d976091cf191
Author: user
Date: Sat Apr 4 09:58:12 2015 +0300
Move file
diff --git a/test.pl b/test/test.pl
similarity index 85%
rename from test.pl
rename to test/test.pl
index dd0479d..0d880c8 100644
--- a/test.pl
+++ b/test/test.pl
@@ -2,4 +2,5 @@
use Modern::Perl;
+#comment
say "Hello, world";
但在我的情况下,我已经处理了文件,因此我想将日志消息限制为某个
$ git log -p -M test.pl
commit 9841f31f283c74ec9e2a33869590d976091cf191
Author: user
Date: Sat Apr 4 09:58:12 2015 +0300
Move file
diff --git a/test/test.pl b/test/test.pl
new file mode 100644
index 0000000..0d880c8
--- /dev/null
+++ b/test/test.pl
@@ -0,0 +1,6 @@
+#/usr/bin/perl
+
+use Modern::Perl;
+
+#comment
+say "Hello, world";
正如您所看到的,diff --git a/test/test.pl b/test/test.pl
git在这种情况下无法识别重命名。
那是git BUG还是我必须使用不同的选项?
ANSWER 只想在我的情况下显示输出:
$ git log -p --follow test.pl
commit 9841f31f283c74ec9e2a33869590d976091cf191
Author: user
Date: Sat Apr 4 09:58:12 2015 +0300
Move file
diff --git a/test.pl b/test/test.pl
similarity index 85%
rename from test.pl
rename to test/test.pl
index dd0479d..0d880c8 100644
--- a/test.pl
+++ b/test/test.pl
@@ -2,4 +2,5 @@
use Modern::Perl;
+#comment
say "Hello, world";
如果您注意到,使用此标志--follow
diff做正确的事情:
diff --git a/test.pl b/test/test.pl
答案 0 :(得分:1)
我认为你想要的是--follow
选项
--follow Continue listing the history of a file beyond renames (works only for a single file).
尝试git log -p --follow test.pl
。
测试存储库中的示例如下所示:
commit 16da3d589da102e11c822b0bec931eed41c35e25
Author: John Szakmeister <john@szakmeister.net>
Date: Sat Apr 4 04:19:51 2015 -0400
rename and add *
diff --git a/foo.txt b/bar.txt
similarity index 92%
rename from foo.txt
rename to bar.txt
index 0ff3bbb..e431201 100644
--- a/foo.txt
+++ b/bar.txt
@@ -10,7 +10,7 @@
10
11
12
-13
+13*
14
15
16
commit 3eaef5c6993c6f7df4df457359cb21da8ab75539
Author: John Szakmeister <john@szakmeister.net>
Date: Sat Apr 4 04:19:16 2015 -0400
add foo
diff --git a/foo.txt b/foo.txt
new file mode 100644
index 0000000..0ff3bbb
--- /dev/null
+++ b/foo.txt
@@ -0,0 +1,20 @@
+1
+2
+3
+4
+5
+6
+7
+8
+9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
如果没有--follow
,你会得到:
commit 16da3d589da102e11c822b0bec931eed41c35e25
Author: John Szakmeister <john@szakmeister.net>
Date: Sat Apr 4 04:19:51 2015 -0400
rename and add *
diff --git a/bar.txt b/bar.txt
new file mode 100644
index 0000000..e431201
--- /dev/null
+++ b/bar.txt
@@ -0,0 +1,20 @@
+1
+2
+3
+4
+5
+6
+7
+8
+9
+10
+11
+12
+13*
+14
+15
+16
+17
+18
+19
+20