【问题标题】:How to remove node_modules form unstaged tab?如何从 unstaged 选项卡中删除 node_modules?
【发布时间】:2018-09-13 03:56:06
【问题描述】:

我有一些来自 Git 选项卡中 node_modules 的未暂存文件。我想删除它们,因为文件太多而我看不到好的文件。这是我正在谈论的图片:

Link for image

我尝试过让它们都变味,但它不起作用。我可以暂存普通文件,但从 node_modules/.bin 等它就在那里。

我有这个 .gitignore 文件:

/node_modules/*
/public/hot
/public/storage
/storage/*.key
/vendor
/.idea
/.vscode
/.vagrant
Homestead.json
Homestead.yaml
npm-debug.log
yarn-error.log
.env
.phpunit.result.cache

【问题讨论】:

    标签: git atom-editor


    【解决方案1】:

    您可能已将 node_modules/ 添加到您的索引中。使用 git bash 转到该目录并从索引中删除 node_modules 目录并提交该更改:

    git rm --cached -r node_modules
    git commit -m "removing node_modules from index"
    

    【讨论】:

    • 谢谢,这是我需要的,我认为 git checkout Head 的另一种方法有效,但这个方法很安全
    【解决方案2】:

    首先 在 .git/config 中设置以下变量:

    > [core]
    >     autocrlf = false
    >     safecrlf = false
    >     eol = crlf
    

    然后

    然后运行$ git checkout HEAD .

    1. 选择您要删除的内容
    2. 右键单击并删除/放弃

    【讨论】:

    • 谢谢,但为什么会有,重要吗?希望我不要丢弃重要的东西。它们都是空白,但不知道为什么会出现在那里。
    • 你只需要丢弃不重要的东西!谨防。它可以只是一条线,它作为变化出现的事件。有时这是 git 管道中的错误
    • @AdrianKevin 我不能 100% 确定这是您所面临的,但是:如果您过去 git added 文件,那么将它们添加到 .gitignore 不会阻止 git 跟踪它们。
    • Ofc 但是我是怎么知道的以及为什么我不能暂存并将节点文件推送给他们
    • 一个例子,有来自 .bin 和 empty 以及一些奇怪的 webpack
    猜你喜欢
    • 1970-01-01
    • 2011-03-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多