当我运行此命令时:
git log HEAD..other_branch -- some_file.txt
Run Code Online (Sandbox Code Playgroud)
有没有输出,我认为meants,有没有改变some_file.txt在other_branch.然而,当我跑步时,git merge other_branch我得到了一大堆冲突some_file.txt.
当我跑:
git log HEAD...other_branch -- some_file.txt
Run Code Online (Sandbox Code Playgroud)
我得到两个提交.修改文件的位置和修改文件的分区合并到的位置HEAD.
我假设因为文件只在一个分支中更改,所以不存在任何冲突.为什么会有冲突?有没有办法在我跑之前看到会发生什么冲突git merge?
添加 manojlds 的贡献:
很不错。但接下来应该完成同样的任务吗?
git diff master:some_file.txt someBranch:some_file.txt
Run Code Online (Sandbox Code Playgroud)
这样你就不需要在与缓存进行比较之前检查
原答案:
命令
git log HEAD..other_branch -- some_file.txt
Run Code Online (Sandbox Code Playgroud)
与
git log ^HEAD other_branch -- some_file.txt
Run Code Online (Sandbox Code Playgroud)
这意味着给我从 other_branch 可以访问但从 HEAD 无法访问 some_file.txt 的所有提交的日志。如果此命令没有给您输出,则意味着 other_branch 上的 some_file.txt 根本没有更改。
另一方面:
git log HEAD...other_branch -- some_file.txt
Run Code Online (Sandbox Code Playgroud)
是 HEAD 和 other_branch 之间的对称差异,即 HEAD 和 other_branch 中但不在两者中的提交,并且是合并两个分支时将合并的提交。因此 HEAD 上的 some_file.txt 可能发生了一些事情,导致与 other_branch 上的版本发生冲突
| 归档时间: |
|
| 查看次数: |
291 次 |
| 最近记录: |