删除.gitignore后,git仍然出错?

时间:2014-12-10 19:21:51

标签: git gitignore

根据这个问题的建议: Ignore files that have already been committed to a Git repository

我们做了以下事情:

git rm -r --cached .
git add .
$ git commit -m".gitignore is now working"
On branch master
Your branch and 'origin/master' have diverged,
and have 2 and 24 different commits each, respectively.
  (use "git pull" to merge the remote branch into yours)
git commit -m".gitignore now works"
git pull

git says:
$ git pull
error: The following untracked working tree files would be overwritten by merge:
dir/.classpath

我们如何强制git忽略.classpath文件?

1 个答案:

答案 0 :(得分:1)

您需要在提取之前提交更改:

git rm -r --cached .
git add .
git commit -m 'Removed dir/.classpath'
git pull

根据上游提交,这可能会导致合并冲突。如果你得到一个"修改/删除"合并dir/.classpath中的冲突,您需要在提交合并之前再次将其删除。

git rm -r dir/.classpath
git commit # Commit the merge

编辑:由于您已经提交了更改,因此您需要做的就是在提取之前删除未跟踪的目录。如果您需要目录内容,可能需要先备份

rm -rf dir/.classpath
git pull