Reputation: 25113
Yes, I can do that with help of next command:
$ 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";
But in my case I have handred files, so I want to restrict log messages to certain one
$ 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";
As you can see diff --git a/test/test.pl b/test/test.pl
git do not recognize rename in this case.
Is that the git BUG or must I use different options?
ANSWER just want to show output in my case:
$ 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";
If you notice, with this flag --follow
diff do right thing:
diff --git a/test.pl b/test/test.pl
Upvotes: 1
Views: 46
Reputation: 46992
I think what you want here is the --follow
option
--follow Continue listing the history of a file beyond renames (works only for a single file).
Try git log -p --follow test.pl
.
An example in a test repository looks like:
commit 16da3d589da102e11c822b0bec931eed41c35e25
Author: John Szakmeister <[email protected]>
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 <[email protected]>
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
Without --follow
, you get:
commit 16da3d589da102e11c822b0bec931eed41c35e25
Author: John Szakmeister <[email protected]>
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
Upvotes: 1