我在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/*怎么样?没有测试,但应该可以

其他回答

使用.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.

虽然我切换到Rubymine的时间并不长,但我发现忽略Rubymine的.idea文件并将其提交给git是一件很有挑战性的事情。

以下是我的解决方法

如果你根本没有做过任何分期/提交,或者你刚刚在我的Ruby中启动了一个新项目,那么就简单地这样做

选项1

将下面的代码行添加到.gitignore文件中,该文件通常位于存储库的根目录。

# Ignore .idea files
.idea/

这将确保git忽略所有的。idea文件,尽管它们仍然保留在本地的项目文件夹中。

选项2

如果你已经做了一些分期/提交,或者你刚刚在Ruby我的开发中打开了一个现有的项目,那么就简单地这样做

在终端/命令行中运行代码

git rm -r --cached .idea

这将删除git中已经跟踪的。idea文件

接下来,将.idea/包含到.gitignore文件中,该文件通常位于存储库的根目录。

# Ignore .idea files
.idea/

这将确保git忽略所有的。idea文件,尽管它们仍然保留在本地的项目文件夹中。

选项3

如果你已经做了一些staging/commit,或者你刚刚在Ruby mine中打开了一个现有的项目,并且想在本地和git中完全删除.idea文件,那么就简单地这样做

在终端/命令行中运行代码

git rm -r --cached .idea

这将删除git中已经跟踪的。idea文件

在终端/命令行中运行代码

rm -r .idea

这将删除包括本地文件夹在内的所有。idea文件

接下来,将.idea/包含到.gitignore文件中,该文件通常位于存储库的根目录。

# Ignore .idea files
.idea/

这将确保git忽略所有的。idea文件,并从本地项目文件夹中删除。

这是所有

我希望这对你们有帮助

只是.idea/对我来说很好

JetBrains在GitHub上有一个.gitignore_global。