我应该如何处理用户特定的配置文件(例如:.idea /)? [英] What should I do about user-specific config files (example: .idea/)?

查看:231
本文介绍了我应该如何处理用户特定的配置文件(例如:.idea /)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的工作目录中有一些配置文件( .idea / )来自IDE,Git将它们列为未追踪文件。我应该如何将这些添加到 .gitignore 中(它会被推送到主要回购)或

  • 使用本地选项

      git update -index --assume-unchanged<文件名称> 


  • 或者完全按照不同的方式进行操作?

    最佳做法是什么?

    解决方案

    这些文件特定于您自己的机器/设置。您应该确实忽略它们。



    然而,您应该 只需在项目的中添加与这些文件相对应的条目。 gitignore 。相反,您应该通过全球<$ c $忽略这些文件c> .gitignore

      git config --global core.excludesfile<路径到全局忽略-文件> 

    为什么不在项目的 .gitignore ?请记住,该文件将被项目中的所有协作者使用,因此您希望保持它干净整洁;将特定于用户的条目添加到特定于存储库的 .gitignore 中将会膨胀/污染后者,并导致不必要的精神开销。



    例如,想象一个合作者Bob,可以在Mac OS X上工作,而另一个合作者Alice可以在Windows上工作。 Bob可能希望忽略 .DS_Store 文件,而Alice可能希望忽略 thumbs.db 文件。但是,Bob不需要忽略 thumbs.db 文件,Alice不需要忽略 .DS_Store 文件。因此,他们不应该造成彼此无用的gitignore条目。他们最好通过本地机器的 .gitignore 文件忽略这些文件。


    I've got some config files (.idea/) from an IDE in my working directory, and Git lists these as Untracked files. Should I

    1. add these to the .gitignore (which will get pushed to the main repo), or
    2. use the local option of

      git update-index --assume-unchanged <name of file>
      

    3. or follow a different approach altogether?

    What's best practice?

    解决方案

    Those files are specific to your own machine/setup. You should indeed ignore them.

    However, you should not simply add entries corresponding to those files in the project's .gitignore. Instead, you should ignore those files via a global .gitignore:

    git config --global core.excludesfile <path-to-global-ignore-file>
    

    Why not just add entries in the project's .gitignore? Remember that this file is going to be used by all collaborators in the project, so you want to keep it clean and tidy; adding user-specific entries to a repository-specific .gitignore will just bloat/pollute the latter, and contribute to unnecessary mental overhead.

    For instance, imagine that one collaborator, Bob, works on Mac OS X, whereas another collaborator, Alice, works on Windows. Bob probably wants to ignore .DS_Store files, whereas, Alice probably wants to ignore thumbs.db files. However, Bob has no need to ignore thumbs.db files, and Alice has no need to ignore .DS_Store files. Therefore, they shouldn't inflict a useless gitignore entry on each other. They would do better to ignore such files via a .gitignore file local to their machines.

    这篇关于我应该如何处理用户特定的配置文件(例如:.idea /)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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