I use Rubymine for Rails projects. Very often, Rubymine makes changes in .idea/*
files that I don't care about. But it keeps preventing me from checking out new branches, and makes my version of .idea/
different from my coworkers.
We already added .idea/
to .gitignore
, but it keeps tracking changes in .idea
. How should I do this the right way?
Below is one of typical error messages I got:
error: Your local changes to the following files would be overwritten by checkout:
.idea/workspace.xml
Try git rm -r --cached .idea
in your terminal. It disables the change tracking.
只是.idea/
对我来说很好用
Note that JetBrains recommends "If you decide to share IDE project files with other developers...", tracking all the .idea/*
files except for the following :
So to follow their advice, you would add those to your .gitignore.
Source:
If you decide to share IDE project files with other developers, follow these guidelines:
...
Here is what you need to share:
- All the files under .idea directory in the project root except the workspace.xml , usage.statistics.xml , and tasks.xml files and the shelf directory which store user specific settings
- ...
How to manage projects under Version Control Systems ( archive )
There's some additional notes and discussion on that page that you should read if you're considering going ahead with this,
including additional files you may want to gitignore even if you decided you want to share IDE files (eg .iml files, .idea/modules.xml, gradle.xml, user dictionaries folder, additional files that are generated from gradle or maven).
将.idea/*
添加到排除列表以防止跟踪所有 .idea 文件、目录和子资源。
if a file is already being tracked by Git, adding the file to .gitignore won't stop Git from tracking it. You'll need to do git rm the offending file(s) first, then add to your .gitignore.
Adding .idea/ should work
using git rm -r --cached .idea
in your terminal worked great for me. It disables the change tracking and unset a number of files under the rubymine folder (idea/) that I could then add and commit to git, thus removing the comparison and allowing the gitignore setting of .idea/
to work.
Close PHP Storm in terminal go to the project folder type
git rm -rf .idea; git commit -m "delete .idea"; git push;
Then go to project folder and delete the folder .idea
sudo rm -r .idea/
Start PhpStorm and you are done
In the rubymine gui, there is an ignore list (settings/version control). Maybe try disabling it there. I got the hint from their support guys.
While it's not been too long that I made the switch to Rubymine, I found it challenging ignoring .idea files of Rubymine from been committed to git.
Here's how I fixed it
If you've not done any staging/commit at all, or you just spinned up a new project in Ruby mine, then simply do this
Option 1
Add the line below to the .gitignore file which is usually placed at the root of your repository.
# Ignore .idea files
.idea/
This will ensure that all .idea files are ignored from been tracked by git, although they will still remain in your project folder locally.
Option 2
If you've however done some staging/commit, or you just opened up an existing project in Ruby mine, then simply do this
Run the code in your terminal/command line
git rm -r --cached .idea
This deletes already tracked .idea files in git
Next, include .idea/ to the .gitignore file which is usually placed at the root of your repository.
# Ignore .idea files
.idea/
This will ensure that all .idea files are ignored from been tracked by git, although they will still remain in your project folder locally.
Option 3
If you've however done some staging/commit, or you just opened up an existing project in Ruby mine, and want to totally delete .idea files locally and in git, then simply do this
Run the code in your terminal/command line
git rm -r --cached .idea
This deletes already tracked .idea files in git
Run the code in your terminal/command line
rm -r .idea
This deletes all .idea files including the folder locally
Next, include .idea/ to the .gitignore file which is usually placed at the root of your repository.
# Ignore .idea files
.idea/
This will ensure that all .idea files are ignored from been tracked by git, and also deleted from your project folder locally.
That's all
I hope this helps
Add .idea to ~/.gitignore_global and follow the instructions here to get .gitignore_global working:
Then you don't have to ever add it to an individual .gitignore file.
对我来说,只有一种解决方案可以删除 .idea 文件夹,而不是使用“.idea”提交文件 .gitignore 然后再次使用 IDE
I suggest reading the git man page to fully understand how ignore work, and in the future you'll thank me ;)
Relevant to your problem:
Two consecutive asterisks ("**") in patterns matched against full pathname may have special meaning:
A leading "**" followed by a slash means match in all directories. For example, "**/foo" matches file or directory "foo" anywhere, the same as pattern "foo". "**/foo/bar" matches file or directory "bar" anywhere that is directly under directory "foo".
A trailing "/**" matches everything inside. For example, "abc/**" matches all files inside directory "abc", relative to the location of the . gitignore file, with infinite depth.
A slash followed by two consecutive asterisks then a slash matches zero or more directories. For example, "a/**/b" matches "a/b", "a/x/b", "a/x/y/b" and so on.
Other consecutive asterisks are considered invalid.
You may use gitignore for advanced gitignore file generation. It's fast, easy and cutting edge tags are automatically generated for you.
Use this link for most of jetbrains softwares ( intelij , phpstorm ...) jetbrains .gitignore file
[edit]
Below is the generated gitignore file for Jetbrains Softwares, this will prevent you from sharing sensitive informations (passwords, keystores, db passwords...) used by any of Jetbrains software to manage projects.
# Created by https://www.gitignore.io
### Intellij ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm
*.iml
## Directory-based project format:
.idea/
# if you remove the above rule, at least ignore the following:
# User-specific stuff:
# .idea/workspace.xml
# .idea/tasks.xml
# .idea/dictionaries
# Sensitive or high-churn files:
# .idea/dataSources.ids
# .idea/dataSources.xml
# .idea/sqlDataSources.xml
# .idea/dynamic.xml
# .idea/uiDesigner.xml
# Gradle:
# .idea/gradle.xml
# .idea/libraries
# Mongo Explorer plugin:
# .idea/mongoSettings.xml
## File-based project format:
*.ipr
*.iws
## Plugin-specific files:
# IntelliJ
/out/
# mpeltonen/sbt-idea plugin
.idea_modules/
# JIRA plugin
atlassian-ide-plugin.xml
# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
Generated code is also well commented. hope it helps :)
I tried to added those files into my .gitignore
and it was useless...
Nevertheless, as Petr Syrov said, you can use git rm -r --cached .idea
into your terminal and those files won't be a problem anymore!
JetBrains 在 GitHub 上有一个.gitignore_global
。
What about .idea/*
? Didn't test, but it should do it
For all JetBrains IDEs:
Settings > Editor > File Types > Ignored Files and Folders, press + sign and add .idea
to ignored list.
Alternatively, add to .gitignore
(for committing) or .git/info/exclude
(for local) the line .idea/
.
Use .ignore plugin: https://plugins.jetbrains.com/plugin/7495--ignore
It manages a lot of paths/patterns for you automatically and also has many useful extra features. It's compatible with:
If you've already made an initial commit and you have .idea files showing up as new files in git, you will need to remove the files first and then commit them. The following steps will do the trick
1. git rm --cached -r .idea/
2. Add .idea/ to **.git/info/exclude** or **.gitignore**
3. git commit -m 'ignore .idea/ files'
It's explained in detail in this link here: https://devconnected.com/how-to-clear-git-cache/
.gitignore, which is a file used to explicitly specify which files or folders should be ignored by Git
The ignore rules specified in $HOME/.gitignore_global , $HOME/.config/git/ignore , $GIT_DIR/info/exclude , .gitignore are all in effect in the Git repository
A .gitignore file explicitly specifies which files should not be tracked by Git, ie, ignored by Git. Files that were already tracked by Git before being gitignore are not affected by the gitignore rule. . To stop tracking a file that is already tracked by Git, use the git rm --cached .idea/
command
On Windows. Just make the .idea folder hidden. Git will take care of the rest.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.