[英]Git - Diff between branches in old commits
I have this: 我有这个:
branch: commit 1, commit 2, 3,4
master: commit 1, commit 2, 3,4,5,6,7
How can you make a diff between branch after commit 2
(in that point of history) and master in commit 3
? 如何在
commit 2
(在历史记录点)和commit 3
master之后在分支之间进行区分?
Let's name your commits b1, b2, b3, b4; 让我们为你的提交命名b1,b2,b3,b4; m1, m2, m3, m4, m5, m6, m7.
m1,m2,m3,m4,m5,m6,m7。 To diff two commits you can run
git diff commit1 commit2
. 要进行两次提交,可以运行
git diff commit1 commit2
。 In your case it's git diff b2 m3
. 在你的情况下,它是
git diff b2 m3
。
You can always and in any time check the difference between commits with 您可以随时随地检查提交之间的区别
git diff commit1..commit2
You can substitute commit with branch names. 您可以使用分支名称替换commit。
git diff master..foo
or also with HEAD 或者还有HEAD
git diff master..HEAD
and so on. 等等。
Here a real example: 这是一个真实的例子:
git diff e8e1956c174da9d..90f2b3ee988d8b6
Note that the complete hash is not necessary. 请注意,不需要完整的哈希。
The detailed answer could be: 详细的答案可能是:
First checkout branch: git checkout branch 第一个结帐分支:git checkout分支
Then run: git log 然后运行:git log
Get the SHA/commit-id of the commit you want and copy it. 获取所需提交的SHA / commit-id并将其复制。 (I am calling it SHA1)
(我称之为SHA1)
Then go back to the master branch: git checkout master 然后回到主分支:git checkout master
Then run: git log 然后运行:git log
Get the SHA/commit-id of the commit you want and copy it. 获取所需提交的SHA / commit-id并将其复制。 (I am calling it SHA2)
(我称之为SHA2)
Then while staying on Master, you can run: git diff SHA1 SHA2 然后继续使用Master,你可以运行:git diff SHA1 SHA2
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.