使用git查看对特定文件的更改 [英] See changes to a specific file using git
问题描述
我知道我可以使用git diff
命令来检查更改,但是据我所知,它是基于目录的.这意味着它将提供当前目录中所有文件的所有更改.
I know that I can use the git diff
command to check the changes, but, as far as I understood, it is directory based. This means it gives all the changes of all files on the current directory.
如何只检查一个特定文件中的更改?说,我已经更改了文件file_1.rb
,file_2.rb
,...,file_N.rb
,但是我只对文件file_2.rb
中的更改.然后(在我提交之前)如何检查这些更改?
How can I check only the changes in one specific file? Say, I have changed files file_1.rb
, file_2.rb
, ..., file_N.rb
, but I am only interested in the changes in the file file_2.rb
. How do I check these changes then (before I commit)?
推荐答案
使用如下命令:
git diff file_2.rb
有关各种内容的完整信息,请参见 git diff
文档您可以得到与众不同.
See the git diff
documentation for full information on the kinds of things you can get differences for.
通常,git diff
本身会显示整个存储库(不仅仅是当前目录)中的所有更改.
Normally, git diff
by itself shows all the changes in the whole repository (not just the current directory).
这篇关于使用git查看对特定文件的更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!