无法在Idea IDE中撤销更改

4

我有几个文件显示为已更改。如果我还原更改,什么也不会发生。如果我从磁盘中删除它们,然后从控制台运行git checkout -- .,它们会再次显示为已更改。

如何让Idea忘记它们?

其他操作(如拉取、提交和推送)正常工作。

操作系统:Windows 7。

$ git config core.fileMode
false

$ git status
# On branch bugfix/XXXXX
nothing to commit (working directory clean)

哪些文件?它们是 .iml 还是 .ipr? - Software Engineer
在 IntelliJ IDEA 中,git pull 是否正常工作? - Sezin Karli
我没有很清楚地理解你的意思,你是想撤销那些更改吗?还是说你不想看到文件状态(已更改/已修改)? - Anjaneyulu Battula
1
你的操作系统是什么?另外,能告诉我 git config core.autocrlf 的输出结果吗?还有哪些问题文件中的行结束符?我想你可能已经猜到我怀疑什么了 ;) - Lucas Trzesniewski
出现了什么样的变化? - phts
显示剩余6条评论
5个回答

8

我猜问题出在文件模式上!我之前把我的开发环境迁移到Windows时也遇到过这个问题。

尝试运行git config core.fileMode false,然后再检查一下!

希望能帮到你!


没有问题,可能是其他方面的原因。 - talex

3
  • By using git status we can find out each file status (modified, not modified).

  • In our project, temporary files frequently change. In this case, git repository says our files are untracked or modified. For this we have to add these files to .gitignore to ignore them.

    We have to execute some commands. Please refer to this question and check the following commands.

    git reset HEAD filenamewithpath -> unstaging a staged file
    git checkout -- filenamewithpath -> unmodifying a modified file
    
  • You can find the relevant technology's .gitignore files in this GitHub repository.

  • To ignore the files which we mentioned in the .gitignore file, we have to execute the following commands.

    git rm -r --cached .
    git add .
    git commit -m ".gitignore is now working"
    

你在项目中添加了 .gitignore 文件吗?使用 git status 命令后,你发现有没有未跟踪的文件? - Anjaneyulu Battula
жҳҜзҡ„пјҢйЎ№зӣ®дёӯжңү.gitignoreж–Ү件гҖӮиҖҢдё”git statusжІЎжңүжҳҫзӨәд»»дҪ•жӣҙж”№гҖӮ - talex
嗯,也许问题是由于IDE的版本问题,请检查它是否是最新版本。 - Anjaneyulu Battula
问题不在于.gitignore文件。这些文件是项目的一部分,并已经提交到仓库中。 - talex
git status 命令将显示未跟踪和已修改的文件,但在您的情况下未显示。我认为已更改的文件不在 git 代码库 中,请检查一下。 - Anjaneyulu Battula
仓库中的文件。我尝试在本地删除它们并从仓库恢复,但没有帮助。 - talex

1

Idea在“Ctrl + D”和“git status”下没有显示任何更改。因此,这不是行尾问题。 - talex

1
在VCS菜单下有一个“刷新文件状态”的选项。尝试一下也无妨。

尝试过了,没有帮助。 - talex

1

这不是完美的解决方案。但是对于我的问题来说,某种想法的魔法解决方案也很神奇。

当我检出另一个分支时,更改会消失。如果我检出初始分支,它会再次发生。

神奇的事情发生了 :)


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接