gpt4 book ai didi

git - 无法在 git 中提交某些文件的本地更改

转载 作者:太空狗 更新时间:2023-10-29 14:19:58 26 4
gpt4 key购买 nike

我在文件 .classpath 中对远程存储库进行了一些本地更改。 (是的,我知道我不应该在共享存储库中包含类路径文件,但那是另一回事。)

这证明局部有一些变化:

$ git checkout master
error: Your local changes to the following files would be overwritten by checkout:
PhotoFeed/.classpath
Please, commit your changes or stash them before you can switch branches.
Aborting

但是,它们不会出现在 git status 中:

$ git status
# On branch release-1.5.1
nothing to commit, working directory clean

这个文件不在 .gitignore 中,因为这个命令证明:

$ git status --ignored
# On branch release-1.5.1
# Ignored files:
# (use "git add -f <file>..." to include in what will be committed)
#
# .metadata/
# PhotoFeed/.settings/
# PhotoFeed/bin/

我也尝试将它从 assume-unchanged 中删除,但它没有改变任何东西:

$ git update-index --no-assume-unchanged PhotoFeed/.classpath

不能添加到暂存区。我可以对它执行 git add -f,但是 git commit 一直说没有什么可以提交。

如何使这个文件再次“正常”?我希望能够对它进行 diff、提交,或者只是 git rm。也就是说,还有哪些其他 git 配置文件/标志/属性可能 stash 了这个文件?

最佳答案

还有一个用于忽略文件的git配置文件:.git/info/exclude

文件exclude.gitignore 之间的区别在于前者没有版本控制,仅供您个人使用。例如,从您的 IDE 或操作系统中排除文件。

关于git - 无法在 git 中提交某些文件的本地更改,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18276379/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com