git diff 是合并提交所特有的
假设我有,
A topic
/ \
D---E---F master
执行相同的操作轻松获得 DE 的差异
git diff D..E --name-status
我可以通过对 EF 和 EA
。提交F是一个合并提交,并说它有冲突。通过修改foo.bar解决了。 foo.bar 被 git 添加,然后合并提交被提交。合并冲突已解决。
现在 foo.bar 的更改仅存在于提交 F 中。我如何获取该差异?
有没有办法获取合并提交中唯一引入的文件的差异?
Say I have,
A topic
/ \
D---E---F master
I can easily get the diff of D-E by doing
git diff D..E --name-status
and same for E-F, and E-A.
Commit F is a merge commit, and say it had a conflict. It was resolved by modifying foo.bar. foo.bar was git added, then the merge commit was committed. The merge conflict was resolved.
Now the change for foo.bar exists only in commit F. How do I get that diff?
Is there a way to get the diff of files that were uniquely introduced in a merge commit?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
合并提交上的 git show 将会显示不在其任何父级中的更改。例如:
git show
on the merge commit will show changes not in any of its parents. For example:不确定“合并提交中唯一引入的文件”到底是什么意思。该文件之前必须存在,否则不会发生冲突。而且“foo.bar 的更改仅存在于提交 F 中”也不完全正确。提交不包含更改。您可以看到 foo.bar diff 与其他任何差异完全相同:
git diff E F
或git diff A F
,具体取决于您要遵循的分支。Not sure exactly what "files that were uniquely introduced in a merge commit" means. The file had to exist before, or there wouldn't have been a conflict. And "the change for foo.bar exists only in commit F" isn't exactly correct, either. Commits don't contain changes. You can see the foo.bar diff exactly the same as any other:
git diff E F
orgit diff A F
, depending on which branch you want to follow.