我碰巧遇到了这样一种情况,即合并可以有效地回滚提交,而无需以我所知道的任何简单的方式跟踪日志:
* fcfea4c merge code.txt:1 other.txt:a
|\
| * b0f6762 conflict code.txt:1 other.txt:b
* | 9fe5de2 other code.txt:2 other.txt:a
|/
* e0d9522 previous code.txt:1
* 7a466e5 init touch code.txt左边的分支是master,右边的分支是feature,在fcfea4c中合并时,文件other.txt中存在冲突(code.txt应该由git自动合并),如果我在主服务器上运行git checkout HEAD~ .(e0d9522前次提交),然后结束提交,git log code.txt将只显示init(7a466e5)和previous(e0d9522)提交,other(9fe5de2)提交将丢失。那么,是否有一种简单的方法来跟踪code.txt发生了什么(同时显示other和merge提交)?
发布于 2017-09-18 08:47:52
git log --first-parent --graph --all -- code.txt就是答案,--first-parent实际上意味着将合并看作是对特定分支(Follow only the first parent commit upon seeing a merge commit.)的正常提交。
发布于 2017-09-18 04:49:53
你应该试一试:
git checkout --ours -- others.txt这应该保留合并的历史记录,同时保留您要查找的内容。
https://stackoverflow.com/questions/46270360
复制相似问题