node.js - node_modules 在 Azure 中使用本地 git 一遍又一遍地提交问题

标签 node.js git azure azure-web-app-service node-modules

首先,我试图让我的azure应用程序服务托管我的create-react-app,并使用它来存储我的代码,减去node_modules。也就是说,在搜索、询问这里和其他地方之后,我已经从头开始了几次,但每次,当我去推送时,node_modules 不知何故继续坚持上传自身。

我的流程是:

git init,然后touch .gitignore,我的.gitignore看起来像:

# See https://help.github.com/ignore-files/ for more about ignoring files.

# dependencies
node_modules

# production


# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local

npm-debug.log*
yarn-debug.log*
yarn-error.log*
package-lock.json

然后我执行 git add .,然后添加我的 Remote ,然后执行 git commit -m "",然后执行 git push azure master,但无论如何,“node_modules”继续坚持被推送。为什么?

如果我执行git status,可以看到它没有显示node_modules目录,那为什么它还继续往上推呢?这里的图片显示了 git status 的结果:

enter image description here

同样,我已经完成了 3-4 次完全重置,每次的问题都是相同的。您可以看到here我以为我通过另一篇文章找到了解决方案,但尽管采取了这些措施,结果仍然相同。我应该做点别的吗?

更新:

尝试了第一个答案,一切看起来都很好,但随后它再次从 node_modules 开始。您可以在屏幕截图中看到发生了什么:

enter image description here

你知道这是怎么回事吗?这个初始构建使用 create-react-app ,当它点击默认脚本或其他东西时,似乎发生了一些事情。更多想法?

最佳答案

首先,可以肯定的是,忽略文件夹应该以 / 结尾

node_modules/

如果 git status 没有显示该文件夹,您可以检查它是否被忽略:

git check-ignore -v -- node_modules/a_file_within_node_modules

其次,确保node_modules本身没有.git子文件夹。

关于node.js - node_modules 在 Azure 中使用本地 git 一遍又一遍地提交问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48898850/

相关文章:

node.js - 将互联网域名指向套接字流应用程序/端口

node.js - 如何在node.js/socket.io中使用removeListener来防止多次触发函数

git - 我可以让我的 Git 'difftool' 默认应用 '--dir-diff' 吗?

c# - Umbraco v6.1 的 FileSystemProvider

python - 在 python 中连接失败后重试 SQL 连接的正确语法?

node.js - 在 koa 中使用 express 中间件

javascript - 在 EC2 上为 nodejs express 应用监听对端口 3000 的 HTTPS 请求

GitHub 页面 : Changing User site to a Project site

git - 如何将我的更改压缩为单个结果提交并选择主分支?

azure - .NET Core Azure WebJob 跟踪日志仅记录 1 个条目