本文翻译自:Finding diff between current and last version?
使用Git,您如何找到当前版本和最后一个版本之间的差异?
git diff last version:HEAD
#1楼
参考:https://stackoom.com/question/fYMX/查找当前版本和最后版本之间的差异
#2楼
You can do it this way too: 你也可以这样做:
Compare with the previous commit 与之前的提交相比
git diff --name-status HEAD~1..HEAD
Compare with the current and previous two commits 与当前和之前的两个提交进行比较
git diff --name-status HEAD~2..HEAD
#3楼
如果您添加了但尚未提交,请使用cached
标志:
git diff --cached --color
#4楼
Difference between last but one commit and last commit (plus current state, if any): 最后一次提交和最后一次提交之间的区别(加上当前状态,如果有的话):
git diff HEAD~
or even (easier to type) 甚至(更容易打字)
git diff @~
where @
is the synonim for HEAD
of current branch and ~
means "give me the parent of mentioned revision". 其中@
是当前分支的HEAD
的synonim, ~
表示“给我提到的修订版的父级”。
#5楼
正如amalloy的评论所指出的那样 ,如果用“当前版本和最后版本”表示最后一次提交和之前的提交,你可以简单地使用
git show
#6楼
Firstly, use " git log
" to list the logs on the repo. 首先,使用“ git log
”列出repo上的日志。
Now, select the two commit-ids, pertanining to the two commits, you want to see the differences ( Example - Top most commit and some older commit [as per your expectation of current-version and some old version] ). 现在,选择两个commit-id,相关两个提交,你想看到差异( 例子 - 最顶层提交和一些较旧的提交[根据你对当前版本和一些旧版本的期望] )。
Next, use : 接下来,使用:
git diff <commit_id1> <commit_id2>
or 要么
git difftool <commit_id1> <commit_id2>