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

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

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

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

当前回答

如果Git已经在跟踪某个文件,那么将该文件添加到.gitignore不会阻止Git跟踪它。你需要先对有问题的文件进行git管理,然后添加到你的.gitignore中。

加上。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文件在git中显示为新文件,那么您需要先删除这些文件,然后再提交它们。以下步骤将达到目的

 1. git rm --cached -r .idea/
 2. Add .idea/ to **.git/info/exclude** or **.gitignore**
 3. git commit -m 'ignore .idea/ files'

在这个链接中有详细的解释: https://devconnected.com/how-to-clear-git-cache/

在rubymine gui中,有一个忽略列表(设置/版本控制)。也许可以试着在那里禁用它。我从他们的后勤人员那里得到了暗示。

将.idea/*添加到排除列表中,以防止跟踪所有.idea文件、目录和子资源。

在你的终端试试git rm -r——cached .idea。它禁用更改跟踪。