Reputation: 4196
I want check changes in a specific file for a specific commit (by its SHA1).
I have a SHA1 of a git commit - 16a75e59, in this commit several files was changed. I want check changes in only one of them - /www/htdocs/doms/js/Test.js.
I know that this file was changed int this commit: If I run
git show 16a75e59 | grep Test.js
I got
echo Resolve::minify( file_get_contents( '/www/htdocs/doms/js Test.js' ) );
diff --git a/www/htdocs/doms/js/Test.js b/www/htdocs/doms/js/Test.js
--- a/www/htdocs/doms/js/Test.js
+++ b/www/htdocs/doms/js/Test.js
But when I trying
git show 16a75e59 www/htdocs/doms/js/Test.js
I got
fatal: ambiguous argument 'www/htdocs/doms/js/Test.js': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
Update: trying with -- and all works just fine. Seems first time I trying -- with leading slash.
So answer is: git show 16a75e59 -- www/htdocs/doms/js/Test.js
Upvotes: 0
Views: 384
Reputation: 489688
If by "doesn't work" you got a message like this one:
$ git show d8b396e /t/t7509-commit.sh
fatal: ambiguous argument '/t/t7509-commit.sh': unknown
revision or path not in the working tree.
(note: I split the line myself to make it fit better, it's all one line in the original), then it's because /path/to/file.js
contains a leading slash. Remove it:
$ git show d8b396e t/t7509-commit.sh
commit d8b396e17ecfe28b39b5f4470f791c434cce40ec
Author: Fabian Ruch ...
...
diff --git a/t/t7509-commit.sh b/t/t7509-commit.sh
index b61fd3c..9ac7940 100755
--- a/t/t7509-commit.sh
+++ b/t/t7509-commit.sh
(It helps if, in your original question, you show exactly the commands you use and the exact error messages. This often avoids needing to guess at the problem.)
Upvotes: 3
Reputation: 2426
May be you could try the git diff
command
Check this
git diff SHA1^ SHA1 /path/to/file.js
Upvotes: 1