Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何为特定文件显示git?_Git - Fatal编程技术网

如何为特定文件显示git?

如何为特定文件显示git?,git,Git,我想看看在特定的提交中发生了什么变化 没问题 git show 123456 但是这个提交有很多更改,我只想看到一个特定文件的更改 让我试试这个 git show 123456:/foo/bar/my.file 嗯,很有效。但并非如预期的那样。上面的命令将以rev.格式显示整个文件。123456-但我想查看此版本的差异(就像git show 123456一样)。您正在查找git diff命令,如果您想查看提交之间的差异: $ git diff <commit1>..<com

我想看看在特定的提交中发生了什么变化

没问题

git show 123456
但是这个提交有很多更改,我只想看到一个特定文件的更改

让我试试这个

git show 123456:/foo/bar/my.file

嗯,很有效。但并非如预期的那样。上面的命令将以rev.格式显示整个文件。123456-但我想查看此版本的差异(就像
git show 123456
一样)。

您正在查找
git diff
命令,如果您想查看提交之间的差异:

$ git diff <commit1>..<commit2> -- <your_file_path>
$git diff
使用“-”分隔符:

git show 123456 -- /foo/bar/my.file

所以你想在123456和123456^处区分提交,对吗?@Brettetete:不,如果你想在两个版本之间区分,你需要两个SHA。这就是我想要的答案。
git show 123456 -- /foo/bar/my.file