git - 如何在git中关注一个文件

标签 git git-remote git-branch

我在 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/

相关文章:

git - 让 git 显示正在运行内容过滤器的特定文件名

git - 错误 : commit subject >65 characters; use shorter first paragraph

git - 添加了不正确的 Git 远程;无法删除它或用另一个 Remote 覆盖它

GIT:致命: 'master' 似乎不是 git 存储库

git - 如何将 git 远程分支引用带到本地

Git post-receive hook 更新不同用户拥有的本地克隆

java - 使用 Git 查找 TODO 的日期

Git:使用来自不同远程的两个具有相同名称的分支

git - 如何在 Git 中 check out 远程分支?

git - 'git : : number expected' error coming when doing git branch