我对git有个奇怪的问题。我的.gitignore文件似乎已被跟踪,但我无法提交。
命令行:
user@STATION ~/repository (my_first_branch)
$ git checkout my_second_branch
error: Your local changes to the following files would be overwritten by checkout:
.gitignore
Please, commit your changes or stash them before you can switch branches.
Aborting
user@STATION ~/repository (my_first_branch)
$ git add .gitignore
user@STATION ~/repository (my_first_branch)
$ git commit
# On branch my_first_branch
nothing to commit, working directory clean
user@STATION ~/repository (my_first_branch)
$
所以我无法查看其他分支,因为.gitignore并且我对此无能为力。
我找到的唯一解决方案是手动删除.gitignore,但我想跟踪它。文件.gitignore不在我的.gitignored中,我不知道它为什么没有被跟踪。
我不能提交或存储它。
更新:git status:
user@STATION ~/repository (my_first_branch)
$ git status
# On branch my_first_branch
nothing to commit, working directory clean
答案 0 :(得分:0)
如果您真的想要,可以将.gitignore添加到.gitignore文件中,如果您不希望它被提交。但是,在这种情况下,最好将忽略添加到.git / info / exclude,这是一个特殊的checkout-local文件,就像.gitignore一样,但不会出现在“git status”中,因为它位于.git文件夹中。