【发布时间】:2015-08-20 12:12:47
【问题描述】:
Eclipse 有自己的文件.project、.classpath 和.settings 文件夹。在 git 中,我将它们放在 .gitignore 文件中,因为我不希望它们在远程存储库中被跟踪。我的问题是,当我切换分支,然后切换回来时,这些文件已被删除,因此 eclipse 无法识别该项目,我必须再次导入它才能生成它们。
有没有办法告诉 git 忽略这些文件,但将它们保存在本地 repo 或其他东西中,这样我在切换分支时不会丢失它们,但不会跟踪对它们的更改,也不会将它们推送到远程吗?
运行git ls-files -o时显示文件。
我检查了GIT: How to keep ignored files when switching branches?,但在执行git status 时文件仍然出现。
编辑:
git status 单独显示:
$ git status
On branch refactorizacion
Your branch is up-to-date with 'origin/refactorizacion'.
nothing to commit, working directory clean
这不起作用:
$ git add -f .project
$ git rm --cached .project
我也试过这个,但是文件出现在git status之后:
$ git add -f .project
$ git update-index --assume-unchanged .project
$ git status
On branch refactorizacion
Your branch is up-to-date with 'origin/refactorizacion'.
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
new file: .project
【问题讨论】:
-
你能显示你的 git status 的输出吗?
-
@TheGeorgeous 我用更多信息编辑了这个问题
-
@carcaret 您找到问题的解决方案了吗?我也有同样的问题,找不到解决办法。