【问题标题】:What should I put in a meteor .gitignore file?我应该在流星 .gitignore 文件中放入什么?
【发布时间】:2012-05-30 12:48:03
【问题描述】:

我有一个新的流星项目。我猜.meteor 目录有配置文件(需要)和临时文件(不需要)的组合。

那么你的.gitignore 里有什么?

【问题讨论】:

  • settings.json 特别是如果你有 API 令牌。
  • 我使用 webstorm,我的 .gitignore 中唯一的一行是 .idea/

标签: git meteor gitignore


【解决方案1】:

.meteor/local 是您唯一希望从版本控制中删除的内容。

Meteor 会自动生成一个符合您需要的 .gitignore 文件。

如果它是一个公共存储库,您可能希望包含“settings-development.json”或任何其他包含您不想向公众披露的信息(例如 AWS API 密钥)的 JSON 文件。

但是,Bitbucket 和其他一些提供了免费的私有存储库,应该可以满足您的需求。

【讨论】:

    【解决方案2】:

    您可以使用此站点https://www.gitignore.io/ 为任何项目生成 .gitignore 文件,只需插入您使用的技术和您的 IDE

    【讨论】:

      【解决方案3】:
      ### MeteorJS ###
      # default meteor build and local packages
      .meteor/local
      
      # meteor settings file
      settings.json
      
      # meteor build output files
      *.tar.gz
      
      # general swp files from vim
      *.swp
      
      # End of https://www.gitignore.io/api/meteorjs
      

      【讨论】:

        【解决方案4】:

        您需要将已安装的包目录放在根目录中名为 node_modules 的目录中。当您提交项目时,它将被忽略。产品经理也可以使用 package.json 在他们的服务器上轻松安装包。

        【讨论】:

          【解决方案5】:

          我们使用这个 gitignore,它包含许多 IDE 和 Meteor,以及系统文件和其他文件。

          ### WebStorm ###
          .idea/
          
          ### OSX ###
          .DS_Store
          .AppleDouble
          .LSOverride
          # Icon must end with two \r
          Icon
          # Thumbnails
          ._*
          # Files that might appear on external disk
          .Spotlight-V100
          .Trashes
          # Directories potentially created on remote AFP share
          .AppleDB
          .AppleDesktop
          Network Trash Folder
          Temporary Items
          .apdisk
          
          ### Windows ###
          # Windows image file caches
          Thumbs.db
          ehthumbs.db
          # Folder config file
          Desktop.ini
          # Recycle Bin used on file shares
          $RECYCLE.BIN/
          # Windows shortcuts
          *.lnk
          
          ### Linux ###
          *~
          # KDE directory preferences
          .directory
          
          ### SublimeText ###
          # cache files for sublime text
          *.tmlanguage.cache
          *.tmPreferences.cache
          *.stTheme.cache
          # workspace files are user-specific
          *.sublime-workspace
          # project files should be checked into the repository, unless a significant
          # proportion of contributors will probably not be using SublimeText
          # *.sublime-project
          # sftp configuration file
          sftp-config.json
          
          ### Node/NPM ###
          node_modules
          npm-debug.log
          
          ### Development ###
          dump
          mochawesome-reports
          ngrok
          

          【讨论】:

            【解决方案6】:

            这是我在 Intellij 中使用的 .gitignore 文件:

              node_modules/
              .meteor/local/*
              .idea/
              npm-debug.log
              packages/*/.npm/
            

            【讨论】:

              【解决方案7】:

              这是我在 Webstorm 和 Meteor 1.4 中使用 Mupx 部署的内容。

              # Meteor files to ignore now handled by .ignore file within .Meteor folder automatically
              
              # settings file to ignore to protect API keys
              settings.json
              
              # MUP / MUPX file to ignore to protect server passwords and sensitive info.
              mup.json
              
              # npm package files to ignore
              node?modules/
              npm-debug.log
              
              # Webstorm IDE files to ignore
              .idea/*
              
              # Typing type definition files to ignore. Webstorm uses type definitions for autocomplete even without typescript
              typings/*
              

              【讨论】:

                【解决方案8】:
                1. gitignore 用于忽略所有不必要的 git 服务器负担和您一直在获取的内容。
                2. 因此,最好放在 gitignore 中的东西是可打包实体。现在,这包括了流星可下载的包,所以,你应该在 gitignore 中添加“.meteor/local”。
                3. 当您将它添加到 gitignore 配置时,它会将项目的大小减少到使用包时的 n 倍。
                4. 如果您现在将整个项目剪切粘贴到不同的位置或获取没有 .meteor/local 文件夹的存储库并使用流星命令启动项目,流星首先下载所需的包,然后启动服务器。

                【讨论】:

                  【解决方案9】:

                  对于meteor 1.3,您还想忽略node_modules。没有理由将所有库添加到 git,因为您可以通过 npm 安装它们。 node_modules 文件夹很可能比您的应用程序大(不包括 .meteor/local 文件夹)

                  【讨论】:

                    【解决方案10】:

                    如果你使用

                    如果你是mac用户可以忽略DS_Store

                    如果你使用 npm 忽略 npm 会导致如果 windows 和 mac 用户都在同一个项目上工作,因为相同的 npm 版本对于 mac 和 windows 是不同的,它会显示错误。

                    【讨论】:

                    • intellij 的问题是你会失去 ECMAScript 级别。
                    【解决方案11】:

                    您希望从版本控制中排除的唯一目录是.meteor/local

                    Meteor 会自动创建正确的 .meteor.meteor/.gitignore,不过,您不需要做任何事情。

                    【讨论】:

                    • 还是这样吗?因为这个我今天下午开始了一个项目,找不到.gitignore。
                    • 嘿。现在我懂了。它不在项目根目录内,而是在 .meteor 文件夹内。
                    • 我忽略了没有“包”文件的整个 .meteor 目录,现在在不同环境中移动项目没有问题。
                    • 这个答案不正确。如果您使用 settings.json 存储 API 密钥,则应忽略它。
                    • @Jessee 是对的——这不是你想要推迟的事情。答案细节应涵盖这一点;如果你打算在你的流星包中存储敏感信息,你应该 .gitignore 它
                    【解决方案12】:

                    Meteor 默认在.meteor 目录中创建一个.gitignore

                    但是,您项目的 .gitignore 应排除任何敏感数据配置文件和 node_modules

                    【讨论】:

                    • 如果排除 node_modules,则必须在 package.json “依赖项”部分中包含所有子目录。否则它可能会破坏你的部署。
                    【解决方案13】:

                    根据this article,您应该忽略您的settings.json,特别是如果您有环境特定信息以包含API 密钥。

                    【讨论】:

                      【解决方案14】:

                      你的 gitignore 还应该包含:

                      公共/node_modules

                      然后你用一个管理节点模块依赖安装的properly crafted package.json 来补充它。

                      当安装在新的地方时,这将需要 npm install。

                      【讨论】:

                        【解决方案15】:

                        如果您要推送到公共存储库,您可能希望将任何配置设置文件放在那里。

                        我将任何安全敏感数据配置设置(如加密密钥和各种密码)存储在 config.js 中,然后将其放入 .gitignore 或 info/exclude 文件中。我不希望在公共回购中的东西。

                        只是为您的 .gitignore 考虑的额外建议

                        【讨论】:

                        • 您不应忽略此答案,因为接受的答案不会阻止您在 settings.json 中发布您的社交媒体和 AWS 令牌。
                        猜你喜欢
                        • 2018-04-30
                        • 1970-01-01
                        • 1970-01-01
                        • 2021-06-15
                        • 2019-05-01
                        • 2012-03-29
                        • 2023-01-29
                        • 1970-01-01
                        • 1970-01-01
                        相关资源
                        最近更新 更多