我在 git 中删除了一个文件几次,但随着其他分支的 merge ,它又不断出现;我猜是这样的:
o-- a topic --o
/ \
o-- [create file] --o-- [delete file] --o-- [file exists again]
自从我们使用“内部发布”与 git 合作以来,我特别难以掌握正在发生的事情,即我创建我推送的发布分支,我们的发布经理将其 pull 下并 merge 到 master,然后我 pull 下他的 master。
我如何找出我(或其他人)删除文件的位置以及重新引入该文件的哪些 merge ?谢谢!
最佳答案
当您在一个分支中删除一个文件,然后 merge 到另一个确实包含该文件的分支中时,该文件将保持删除状态。现在,即使您删除了分支中的文件并将该分支与另一个分支 merge ,它仍然会被删除。
git merge: Removing files I want to keep!
但是,如果将某些内容添加到此文件,在 merge 时,您将遇到冲突,您将必须显式添加此文件并提交以使其返回到您删除的分支。
git log
中有--follow
--follow
Continue listing the history of a file beyond renames (works only for a single file).
但我不确定这是否是您在这里寻找的。您还可以查看 git log
手册中的 History Simplification
- http://git-scm.com/docs/git-log
关于git - 如何在git中关注一个文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6019113/