简体   繁体   English

如何从拉取请求中删除 node_modules?

[英]How to remove node_modules from the pull request?

So I contributed to a repository and initially the build failed so I contributed again but somehow this time I did something with the node_modules.所以我贡献了一个存储库,最初构建失败了,所以我再次贡献了,但不知何故,这次我对 node_modules 做了一些事情。 I opened a pull request and now the github repo owner is saying to remove node_modules.我打开了一个拉取请求,现在 github 回购所有者说要删除 node_modules。 I actually changed one file but it is showing something like 8k files changed.我实际上更改了一个文件,但它显示的内容类似于 8k 文件已更改。 Being a newcomer I want to know what has happened and how to resolve this Ie how to remove node modules from the pull request and just commit to that one file only using git.作为一个新手,我想知道发生了什么以及如何解决这个问题,即如何从拉取请求中删除节点模块并仅使用 git 提交到该文件。

I think you have accidentally pushed/added node_modules to your branch.我认为您不小心将 node_modules 推送/添加到您的分支。

To remove it from your PR ->从您的 PR 中删除它 ->

You need to first delete that node_modules folder, and then commit that and push it to remote.您需要先删除该 node_modules 文件夹,然后将其提交并将其推送到远程。 That's it.而已。

After committing the changes, you should reinstall the node_modules as we have deleted them.提交更改后,您应该重新安装 node_modules,因为我们已经删除了它们。 This time this won't be tracked.这一次不会被跟踪。

Generally node_modules are untracked with.gitignore file, but there are ways to push it accidently.一般node_modules是用.gitignore文件不跟踪的,但也有不小心推送的方法。

Two steps: 1) git rm --cached -r node_modules , 2) git commit -m "Removes node_modules"两步:1) git rm --cached -r node_modules , 2) git commit -m "Removes node_modules"

Now you can push to your branch and the PR should be updated现在您可以推送到您的分支,并且 PR 应该会更新

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM