git 不能忽略 .idea/workspace.xml - 不断弹出
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19973506/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Cannot ignore .idea/workspace.xml - keeps popping up
提问by Valentin Despa
Using PHPStorm, I am trying to ignore the workspace.xml
which pops up every-time I try to make a git commit.
使用 PHPStorm,我试图忽略workspace.xml
每次尝试进行 git commit 时弹出的 。
My .gitignore
looks like:
我的.gitignore
样子:
/.idea/
.idea/workspace.xml
Because at a point the file was committed, I've also executed:
因为在提交文件时,我还执行了:
git rm --cached .idea/workspace.xml
and then committed the removal, pushed to a bare repo.
git rm --cached .idea/workspace.xml
然后提交删除,推送到一个裸仓库。
But the file keeps popping up later when I do changes in the project.
但是当我在项目中进行更改时,该文件会不断弹出。
Any ideas on what I am missing?
关于我所缺少的任何想法?
采纳答案by Valentin Despa
I had to:
我不得不:
- remove the file from git
- push the commit to all remotes
- make sure all other committers updated from remote
- 从 git 中删除文件
- 将提交推送到所有遥控器
- 确保所有其他提交者从远程更新
Commands
命令
git rm -f .idea/workspace.xml
git remote | xargs -L1 git push --all
Other committers should run
其他提交者应该运行
git pull
回答by amerdidit
I was facing the same issue, and it drove me up the wall. The issue ended up to be that the .idea folder was ALREADY commited into the repo previously, and so they were being tracked by git regardless of whether you ignored them or not. I would recommend the following, after closing RubyMine/IntelliJ or whatever IDE you are using:
我正面临着同样的问题,它把我逼上了绝路。问题最终是 .idea 文件夹之前已经提交到 repo 中,因此无论您是否忽略它们,git 都会跟踪它们。在关闭 RubyMine/IntelliJ 或您使用的任何 IDE 后,我会推荐以下内容:
mv .idea ../.idea_backup
rm .idea # in case you forgot to close your IDE
git rm -r .idea
git commit -m "Remove .idea from repo"
mv ../.idea_backup .idea
After than make sure to ignore .idea in your .gitignore
之后确保忽略 .gitignore 中的 .idea
Although it is sufficient to ignore it in the repository's .gitignore, I would suggest that you ignore your IDE's dotfiles globally.
尽管在存储库的 .gitignore 中忽略它就足够了,但我建议您全局忽略 IDE 的点文件。
Otherwise you will have to add it to every .gitgnore for every project you work on. Also, if you collaborate with other people, then its best practice not to pollute the project's .gitignore with private configuation that are not specific to the source-code of the project.
否则,您必须将它添加到您工作的每个项目的每个 .gitgnore 中。此外,如果您与其他人合作,那么最好不要使用不特定于项目源代码的私有配置来污染项目的 .gitignore。
回答by arcanine
I had this problem just now, I had to do git rm -f .idea/workspace.xml
now it seems to be gone (I also had to put it into .gitignore
)
我刚才遇到了这个问题,我现在必须做git rm -f .idea/workspace.xml
它似乎消失了(我也不得不把它放进去.gitignore
)
回答by Melski
In the same dir where you see the file appear do:
在您看到文件出现的同一个目录中,请执行以下操作:
rm .idea/workspace.xml
git rm -f .idea/workspace.xml (as suggested by chris vdp)
vi .gitignore
- i(to edit), add
.idea/workspace.xml
in one of the lines, Esc,:wq
rm .idea/workspace.xml
git rm -f .idea/workspace.xml (as suggested by chris vdp)
vi .gitignore
- i(编辑),添加
.idea/workspace.xml
其中一行Esc,,:wq
You should be good now
你现在应该很好
回答by Johnny Willer
To remove .idea/
completely from the git without affecting your IDEconfig you could just do:
要.idea/
在不影响您的 IDE配置的情况下从 git中完全删除,您可以执行以下操作:
git rm -r --cached '.idea/'
echo .idea >> .gitignore
git commit -am "removed .idea/ directory"
回答by kerner1000
If you have multiple projectsin your git repo, .idea/workspace.xml
will not match to any files.
如果您的 git repo 中有多个项目,.idea/workspace.xml
则不会匹配任何文件。
Instead, do the following:
相反,请执行以下操作:
$ git rm -f **/.idea/workspace.xml
$ git rm -f **/.idea/workspace.xml
And make your .gitignore look something like this:
让你的 .gitignore 看起来像这样:
# User-specific stuff:
**/.idea/workspace.xml
**/.idea/tasks.xml
**/.idea/dictionaries
**/.idea/vcs.xml
**/.idea/jsLibraryMappings.xml
# Sensitive or high-churn files:
**/.idea/dataSources.ids
**/.idea/dataSources.xml
**/.idea/dataSources.local.xml
**/.idea/sqlDataSources.xml
**/.idea/dynamic.xml
**/.idea/uiDesigner.xml
## File-based project format:
*.iws
# IntelliJ
/out/
回答by Toskan
Just tell git to not assume it is changed never matter what:
告诉 git 不要假设它被改变了,无论如何:
git update-index --assume-unchanged src/file/to/ignore
yes, you can remove the files from the git repository. But if your team all use the same IDE or you are by yourself, you probably don't want to do that. For yourself, you want to have an ok starting point to resume working, for your teammates as well.
是的,您可以从 git 存储库中删除文件。但是,如果您的团队都使用相同的 IDE,或者您独自一人,您可能不想这样做。对于您自己,您希望有一个好的起点来恢复工作,也为您的队友。
回答by iDon'tKnoware
Same problem for me with PHPStorm
PHPStorm 对我来说也有同样的问题
Finally I solved doing the following:
最后我解决了以下问题:
- Remove .idea/directory
- Move .gitignoreto the same level will be the new generated .idea/
Write the files you need to be ignored, and .idea/too. To be sure it will be ignored I put the following:
- .idea/
- .idea
- .idea/*
- 删除.idea/目录
- 将.gitignore移动到同一级别将是新生成的.idea/
写你需要忽略的文件,还有.idea/。为了确保它会被忽略,我输入了以下内容:
- 。主意/
- 。主意
- 。主意/*
I don't know why works this way, maybe .gitignoreneed to be at the same level of .ideato can be ignored this directory.
我不知道为什么会这样,也许.gitignore需要与.idea处于同一级别才能忽略此目录。
回答by PK Gupta
The way i did in Android Studio which is also based on IntelliJ was like this. In commit dialog, I reverted the change for workspace.xml, then it was moved to unversioned file. After that I deleted this from commit dialog. Now it won't appear in the changelist. Note that my gitignore was already including .idea/workspace.xml
我在同样基于 IntelliJ 的 Android Studio 中的做法是这样的。在提交对话框中,我恢复了对workspace.xml 的更改,然后将其移至未版本控制的文件。之后我从提交对话框中删除了它。现在它不会出现在更改列表中。请注意,我的 gitignore 已经包含 .idea/workspace.xml
回答by Eduard
Since in my case I was performing a first commit of a project, simply deleting .git
and .idea
folders and then reinitializing git using git init
helped to solve a problem. Now I don't have .idea
at all.
因为在我的情况下,我正在执行项目的第一次提交,只需删除.git
和.idea
文件夹,然后使用 help 重新初始化 gitgit init
即可解决问题。现在我完全没有.idea
。