如何在Git中与特定版本的文件进行比较? [英] How can I diff a file with a specific revision in Git?
问题描述
我不知道Git是否具有修订的概念。
I don't know if Git has the concept of a revision.
我想将当前工作副本与旧版本进行比较(不是
I'd like to diff the current working copy with an older version of it (not necessarily the last commit).
如果可以在Emacs中完成,那就太好了。
It would be great if it could be done inside Emacs.
推荐答案
我不知道在Emacs中执行此操作,但是:
I've no idea about doing this inside Emacs, but:
git diff rev1..rev2
将完成整个存储库所需的操作。然后,您可以添加以下内容:
will do what you want for the whole repository. You can then add to that:
git diff rev1>..rev2 path
path
可以是文件的绝对路径,也可以是目录的路径,因此您可以比较子树。
path
can be an absolute path to a file, or a path to a directory, so you can diff subtrees.
如果要比较工作副本-只需指定修订版1:
If you're looking to diff the working copy - just specify revision 1:
git diff rev1 path
修订版代码可以是特殊名称,例如, HEAD ^ .. HEAD
表示当前值的最新值,或它们在日志中的SHA-1值。
The revision codes can be special names, for example, HEAD^..HEAD
means last to current, or their SHA-1 values from the logs.
这篇关于如何在Git中与特定版本的文件进行比较?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!