需要一个将Intellij IDEA项目文件放入Git的策略 [英] Need a strategy to put Intellij IDEA project files in Git

查看:447
本文介绍了需要一个将Intellij IDEA项目文件放入Git的策略的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



主要问题是如何避免分支之间的合并冲突,如果想法项目文件在git中。 / p>

另一个问题是将它们保存在git中是否方便?

解决方案


如何避免合并


您可以保护某些文件不与合作经理


将它们保留在git中很方便


是的,就像。请参阅在版本控制中共享IntelliJ IDEA项目文件

也就是说,只要它们是:


  • 没有任何绝对路径

  • 仅限文本文件

  • 通常 .ipr .iml





      • 规则#1 - 检入 .ipr .iml 文件

      • 规则#2 - 设置 .iws 文件(您的工作区文件)。所有正确的VCS允许你这样做。

      • 规则#3 - 为所有变量制作IDEA项目变量(这有点像变量的定义,你知道)。您可能需要的一些常见变量是Tomcat Home,Groovy Home和JDK Version。


      The Gotchas - 有几个问题需要注意...




      • 使用IDEA的多个版本并不被很好的支持。大多数新版本,甚至是次要版本,都会尝试向项目文件中写入一些额外的信息。

      • 创建JDK名称变量可能会有些混乱,因为它不是磁盘上的路径。 IDEA对所安装的JDK进行全球性(所有项目)跟踪,并为每个JDK命名。在 .ipr 中找到指定位置很容易,但向用户解释应该设置的位置并不容易。它必须是设置中SDK的条目名称。

      • 此外,更改检查配置文件可以修改项目。

        检查是代码类型这个项目,所以把它们放到 .ipr 中是有意义的。但是,这是放置它们的可选位置。检查配置文件可以共享或不共享。如果它被共享,那么它被写入.ipr,否则它是一个外部文件。
      • 最后,向拼写检查器添加单词会将该单词添加到 .ipr 文件,并带有用户名的密钥。我为此打开了一个错误,因为我感觉用户的姓名永远不会进入项目文件,但JetBrains的工作人员认为,考虑到切换到 .idea 备用项目布局会将文件分离出来并避免此问题,所以这是可以做到的。



      Need a strategy to put Intellij IDEA project files into Git.

      The main question is how to avoid merge conflicts between branches if idea project files are in git.

      Another question is it convenient to keep them in git?

      解决方案

      How to avoid merge

      You can protect some files from merges with merge managers.

      Is it convenient to keep them in git

      Yes, like the ones for Eclipse. See Sharing IntelliJ IDEA Project Files in Version Control.
      That is, provided they are:

      • without any absolute path
      • text files only
      • typically .ipr and .iml

      • Rule #1 - Check-in the .ipr and .iml files
      • Rule #2 - Set an ignore flag for the .iws file (your workspace file). All proper VCSs allow you to do this.
      • Rule #3 - Make IDEA Project Variables for all the variables that vary (it's kinda the definition of variable, you know). Some common variables you'll probably need are "Tomcat Home", "Groovy Home", and "JDK Version".

      The Gotchas - There are a few gotcha's to be aware of...

      • Using multiple versions of IDEA is not well supported. Most new versions, even minor releases, try to write some extra info to the project files.
      • Making the JDK Name variable can be somewhat confusing, as it is not a path on your disk. IDEA keeps track globally (for all projects) of your installed JDKs, and each one is given a name. It is easy to find the place in the .ipr where this is specified, but it is not easy to explain to users what their's should be set to. It needs to be the name of an entry from your SDKs in Settings.
      • Also, changing the inspection profiles can modify the project.
        The inspections are the codestyle to the project, so it may make sense to have them baked into the .ipr. However, this is an optional place to put them. An inspection profile can be shared or not. If it is shared then it is written to the .ipr, otherwise it is an external file.
      • Lastly, adding words to the spell checker will add the word to the .ipr file, with a key of your username. I opened a bug for this, as I feel a user's name should never go in the project file, but the JetBrains guys feel that this is OK considering that switching to the ".idea" alternate project layout will separate the files out and avoid the issue

      这篇关于需要一个将Intellij IDEA项目文件放入Git的策略的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆