首先,我试图让我的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
的结果:
同样,我已经完成了 3-4 次完全重置,每次的问题都是相同的。您可以看到here我以为我通过另一篇文章找到了解决方案,但尽管采取了这些措施,结果仍然相同。我应该做点别的吗?
更新:
尝试了第一个答案,一切看起来都很好,但随后它再次从 node_modules
开始。您可以在屏幕截图中看到发生了什么:
你知道这是怎么回事吗?这个初始构建使用 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/