【发布时间】:2013-01-26 00:41:51
【问题描述】:
在我的 gits 中有一个奇怪的问题。没有什么要添加的,但它不会让我切换或添加建议添加的文件。
git status
# On branch oop
nothing to commit (working directory clean)
git checkout LIVE
error: The following untracked working tree files would be overwritten by checkout:
folder/file.js
folder/file2.js
Please move or remove them before you can switch branches.
Aborting
即使在执行git add folder/file.js;git add folder/file2.js 之后,也会出现相同的结果。
有人知道发生了什么吗?没有.gitignore文件...
奇怪的是,之前我无法添加这些文件,所以我不得不重命名、添加、重命名它们才能将它们放入 repo(如 this answer 所建议的那样。
这可能与这个文件夹曾经是这个 repo 中它自己的 repo 的事实有关吗?我删除了此文件夹中的所有隐藏文件夹(如 .git)。
【问题讨论】:
-
它们很可能是您当前分支的
.gitignore的一部分,但不会在 LIVE 分支上被忽略。 -
我检查了 repo 文件夹中的 .gitignore 文件,以及我的主文件夹,它们都是空的。
-
您可以使用
git status --ignored包含被忽略的文件。如果他们出现在那里,他们就会被某处忽略。 -
好主意,但使用
--ignored也没有任何显示:/
标签: git