【问题标题】:node_modules commit issues in Azure with local git over and overnode_modules 在 Azure 中使用本地 git 一遍又一遍地提交问题
【发布时间】:2023-03-30 04:56:02
【问题描述】:

首先,我试图让我的 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 .,然后添加我的遥控器,然后是git commit -m "",然后是git push azure master,但无论如何,“node_modules”继续坚持被推送。为什么?

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

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

更新:

按照第一个答案进行了尝试,一切看起来都很好,但随后又以node_modules 开头。您可以在屏幕截图中看到此处发生的情况:

有什么想法吗?这个最初是使用create-react-app 构建的,当它遇到默认脚本或其他东西时似乎正在发生一些事情。进一步的想法?

【问题讨论】:

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


    【解决方案1】:

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

    node_modules/
    

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

    git check-ignore -v -- node_modules/a_file_within_node_modules
    

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

    【讨论】:

    • 谢谢。检查并按照您的建议进行操作,但仍然得到相同的结果。更新了最初的帖子,提供更多信息,希望能更接近解决方案!
    • @Mark 检查忽略结果是否为空?
    • 这是我得到的结果:git check-ignore -v -- node_modules/accepts/index.js .gitignore:4:node_modules/ node_modules/accepts/index.js 虽然我不确定这是好还是坏。 node_modules 文件夹中也没有 git 文件。
    • 至少那个文件夹没有添加到repo中
    • 如果那个没有被添加,那么从理论上讲,如果都添加到.gitignore,那么它们都不应该被添加,对吧?在这样做时,package.json 中的react-scripts 是否有可能对git push.... 做某事?
    猜你喜欢
    • 1970-01-01
    • 2019-04-16
    • 1970-01-01
    • 2017-10-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多