如果 VS Code 代码在尝试推送大文件时挂起,如何阻止 VS Code 代码推送(同步)到 Git?

发布于 2025-01-15 14:23:00 字数 1151 浏览 3 评论 0原文

问题 - 如何阻止 VS Code 尝试推送到 Git,以便我可以将不需要的大文件/文件夹添加到 gitignore,然后再次继续推送?

我升级了 Angular,它在我的项目中创建了一个文件夹,如下图所示,其中有一个名为“.angular”的文件夹。我忘记将其包含在我的 .gitignore 中,并尝试暂存、提交并推送到我的 Git 存储库。 30 分钟后它仍在运行(尝试推送)。

我确实在 git 输出中收到一条消息,指出检测到大文件:

[2022-03-21T06:14:33.091Z]> git push origin master [29424ms] [2022-03-21T06:14:33.091Z]远程:错误:跟踪:47b6ad853b68f1ff7b533b5b9e1e44880272a4bcbf979e9f8afb162aa47ef3a9​​
远程:错误:请参阅 http://git.io/iEPt8g 了解更多信息。
远程:错误:文件 client/.angular/cache/13.3.0/angular-webpack/5ebe13da59e6342699441237cc06e261c0793966/35.pack 为 113.88 MB;这超出了 GitHub 的文件大小限制 100.00 MB
远程:错误:GH001:检测到大文件。您可能想尝试 Git 大文件存储 - https://git-lfs.github.com

输入图片此处描述

这是 VS Code 中的选项

在此处输入图像描述

QUESTION - How do I stop VS Code from trying to push to Git, so I can add the unneeded large files/folders to gitignore and then proceed to push again?

I upgraded Angular and it created a folder in my project that looks like the image below, with a folder named '.angular'. I forgot to include it in my .gitignore and attempted to stage, commit and push to my Git repo. It's still running (trying to push) 30 minutes later.

I do get a message in the git output that says large file detected:

[2022-03-21T06:14:33.091Z] > git push origin master [29424ms]
[2022-03-21T06:14:33.091Z] remote: error: Trace: 47b6ad853b68f1ff7b533b5b9e1e44880272a4bcbf979e9f8afb162aa47ef3a9
remote: error: See http://git.io/iEPt8g for more information.
remote: error: File client/.angular/cache/13.3.0/angular-webpack/5ebe13da59e6342699441237cc06e261c0793966/35.pack is 113.88 MB; this exceeds GitHub's file size limit of 100.00 MB
remote: error: GH001: Large files detected. You may want to try Git Large File Storage - https://git-lfs.github.com.

enter image description here

Here is what options I have in VS Code

enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

冰雪梦之恋 2025-01-22 14:23:02

我通过重新加载 VSCode 解决了这个问题,然后将 HEAD~1 重置为之前的提交。

I solved it by reloading VSCode and just git reset HEAD~1 to the previous commit.

未央 2025-01-22 14:23:02

您应该解决的真正问题是从该提交中删除大文件。

您可以使用 git filter-branchgit filter-repobfg 删除大文件夹。

如果您恰好刚刚提交了文件(我的意思是最新的提交),您可以使用 git commit --amend 来使最新的提交免于超出限制。


...所以我可以将不需要的大文件/文件夹添加到 gitignore,然后再次继续推送?

不,现在将其添加到 .gitignore 已经太晚了。现在将其添加到 .gitignore 不会将其从 Git 提交历史记录中删除 ->并不能解决突破极限的问题。

I guess the real question you should solve is to remove the huge files from that commit.

You can use git filter-branch, git filter-repo or bfg to remove the large folders.

If you happened to commit the file just now (I mean, the newest commit), you can use git commit --amend to survive the newest commit from pushing limit.


...so I can add the unneeded large files/folders to gitignore and then proceed to push again?

No, it is too late for you to add it to .gitignore now. Adding it to .gitignore now won't remove it from the Git commit history -> won't solve the problem of pushing limit.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文