我应该在Meteor的.gitignore文件中放什么?

155

我有一个新的 Meteor 项目。我猜测 .meteor 文件夹包含了一些配置文件(必需的)和一些临时文件(不需要的)。

那么你的 .gitignore 文件里包含什么呢?


8
settings.json 特别是如果您在其中有 API 令牌。 - Jesse
1
我使用WebStorm,我的.gitignore文件中唯一的一行是.idea/ - Dude
15个回答

209

唯一不想被版本控制的目录是.meteor/local

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


5
这种情况仍然存在吗?因为今天下午我开始了一个项目,但没有找到.gitignore文件。 - akst
17
嘿,现在我明白了。它不在项目根目录中,而是在 .meteor 文件夹中。 - Nek
我忽略了整个 .meteor 目录,但保留了 'packages' 文件,目前在不同的环境中移动项目没有遇到任何问题。 - thinklinux
11
这个答案是不正确的。如果你正在使用 settings.json 存储 API 密钥,那么应该忽略它。 - Jesse
1
@Jessee是正确的 - 这不是你想要推迟的事情。答案细节应该涵盖这一点;如果你要在你的Meteor包中存储敏感信息,你应该.gitignore它。 - lol

22

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

我会将任何安全敏感的数据配置设置(如加密密钥和各种密码,例如smtp、twitter、facebook等)存储在config.js中,然后将其放入.gitignore或info/exclude文件中。我不想让这些东西出现在公共存储库中。

这只是一个额外的建议,可以考虑将其添加到您的.gitignore文件中。


4
不要忽略这个答案,因为接受的答案不能防止你在“settings.json”中发布你的社交媒体和AWS令牌。请注意保密。 - Jesse

11
您的gitignore文件还应包含以下内容:

public/node_modules

并且您需要使用正确编写的package.json来管理node模块依赖项安装。
这将需要在新地方安装时进行npm安装。

7
根据这篇文章,如果您有包括 API 密钥在内的特定于环境的信息,应忽略您的 settings.json

7

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


6
Meteor默认在.meteor目录中创建.gitignore文件。 但是,你的项目的.gitignore应该排除任何敏感数据配置文件和node_modules。

如果你排除了node_modules文件夹,那么你必须在package.json的“dependencies”部分中包含任何子目录。否则可能会影响你的部署。 - Deborah

3

如果你使用的是

如果你是 Mac 用户,请忽略 DS_Store

如果你使用 npm,请忽略 npm。因为如果 Windows 和 Mac 用户在同一项目上工作,由于相同的 npm 版本在 Mac 和 Windows 上不同,会导致错误。


Intellij的问题在于你会失去ECMAScript级别。 - Archimedes Trajano

3
我们使用这个.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

3
这是我在使用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/*

2

您需要将安装的软件包目录命名为node_modules,该目录位于根目录中。在提交项目时,它将被忽略。此外,产品经理可以使用package.json轻松地在他们的服务器上安装软件包。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接