首页 > 解决方案 > 合并两个分支,而目标分支从源分支中保留一个文件

问题描述

我有两个分支,其中一个具有特定文件,我不想在合并期间转到目标分支。我将文件的路径放在目标分支的 .gitignore 文件中,但是在合并过程中,文件来到了它。

这与任何本地计算机无关。这完全在 bitbucket 中作为远程存储库。一个合并到目标分支的分支有一个文件,该文件位于目标分支的 gitignore 列表中。

发生合并时,bitbucket 的目标分支是否会查看 gitignore?
如果是,为什么将文件复制到其中?

标签: gitbitbucketgitignore

解决方案


To take effect of the .gitignore file you must update the index after making changes to .gitignore file

git rm --cached .  #removes indexed files

git add .   # adds back to the index while respecting .gitignore file

then make a commit and push it to the remote branch


推荐阅读