如何使用 Git 查看以前的差异提交?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5901300/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do I view previous diff commits using Git?
提问by lampShade
How do I view previous diff commits using Git?
如何使用 Git 查看以前的差异提交?
I have a file that I've made several commits on, but I want to view previous versions of the file AND its diff's at different stages. Seeing where I made mistakes and how I fixed them is really helping my code. By the way, I'm using Tower as a GUI on top of Git.
我有一个文件,我已经对其进行了多次提交,但我想查看该文件的先前版本及其在不同阶段的差异。看看我在哪里犯了错误以及我是如何修复它们的,这对我的代码很有帮助。顺便说一下,我在 Git 之上使用 Tower 作为 GUI。
回答by Ahmish
git log --full-diff -p your_file_path
Check out:
http://git-scm.com/docs/git-log
回答by Benjamin Bannier
You need git log
. If you were interested in file SOMEFILE
use
你需要git log
. 如果您对文件SOMEFILE
使用感兴趣
$ git log -p SOMEFILE
The -p
option displays the patch which is probably the diff you are looking for.
该-p
选项显示补丁,这可能是您正在寻找的差异。
回答by Sparhawk
If you don't want to specify a particular file, and see the diff for allfiles changed, just use
如果您不想指定特定文件,并查看所有更改的文件的差异,只需使用
$ git log -p