我在Rails项目中使用Rubymine。通常情况下,Rubymine在.idea/*文件中做了一些我并不关心的更改。但它一直阻止我查看新的分支,并使我的.idea版本与我的同事不同。

我们已经向.gitignore添加了.idea/,但它会跟踪.idea中的变化。我该怎么做才对呢?

下面是我得到的一个典型的错误消息:

error: Your local changes to the following files would be overwritten by checkout:
    .idea/workspace.xml

当前回答

.gitignore,该文件用于显式指定Git应该忽略哪些文件或文件夹

在$HOME/中指定的忽略规则。gitignore_global、$ HOME /。config/git/ignore, $GIT_DIR/info/exclude, .gitignore在git存储库中都有效

.gitignore文件显式指定了哪些文件不应该被Git跟踪,即被Git忽略。在gitignore之前已经被Git跟踪的文件不受gitignore规则的影响。要停止跟踪Git已经跟踪的文件,请使用Git rm——cached .idea/命令

其他回答

使用.ignore plugin: https://plugins.jetbrains.com/plugin/7495--ignore

它为你自动管理许多路径/模式,也有许多有用的额外功能。它兼容:

IntelliJ IDEA PhpStorm WebStorm PyCharm RubyMine 本地 CLion GoLand DataGrip 骑手 国会议员 Android工作室

我建议阅读git手册页,以充分理解忽略是如何工作的,将来你会感谢我的;)

与你的问题相关的:

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.

对于所有的JetBrains ide:

设置>编辑器>文件类型>被忽略的文件和文件夹,按+号添加。idea到被忽略列表。

或者,添加到.gitignore(用于提交)或.git/info/exclude(用于本地)行。idea/。

您可以使用gitignore进行高级gitignore文件生成。它是快速,简单和前沿标签自动生成为您。

使用这个链接的大多数jetbrains软件(intelij, phpstorm…) Jetbrains .gitignore文件

(编辑)

下面是为Jetbrains软件生成的gitignore文件,这将防止您共享任何Jetbrains软件用于管理项目的敏感信息(密码,密钥库,数据库密码…)

# 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

生成的代码也有很好的注释。 希望能有所帮助。

.idea/*怎么样?没有测试,但应该可以