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

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

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

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

当前回答

对我来说,只有一个解决方案,删除。idea文件夹,而不是提交文件。gitignore“。然后再次使用IDE

其他回答

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

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

注意,JetBrains建议“如果你决定与其他开发人员共享IDE项目文件……”,跟踪所有的。idea/*文件,除了以下文件:

workspace.xml usage.statistics.xml tasks.xml 货架/目录

因此,为了遵循他们的建议,你可以将这些添加到你的。gitignore中。


来源:

如果您决定与其他开发人员共享IDE项目文件,请遵循以下原则: … 以下是你需要分享的内容: 除了workspace.xml、usage.statistics.xml和tasks.xml文件以及存储用户特定设置的shelf目录外,项目根目录。idea目录下的所有文件 …

如何管理版本控制系统下的项目(存档)

那一页上有一些额外的注释和讨论,如果你考虑继续做这个,你应该读一下, 包括你可能想要gitignore的额外文件,即使你决定要共享IDE文件(例如。iml文件,.idea/modules.xml, gradle.xml,用户字典文件夹,从gradle或maven生成的额外文件)。

我建议阅读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在GitHub上有一个.gitignore_global。