git - 从存储库中删除文件 [英] git - remove file from the repository

查看:107
本文介绍了git - 从存储库中删除文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道已经有一百万个类似的问题,但我不确定他们是否适用。我是 git 的新手,并且有一个托管在github上的项目。我不小心将一些大日志文件添加到存储库中。当我注意到它时,我 git rm 对它们进行了修改,然后对 commit 进行了修改。这似乎已经完成了这项工作,因为当我克隆存储库时,我只能得到我想要的文件(源代码)。然而,克隆现在需要永远的,因为,我认为,由于某种原因,git仍在下载这些日志文件(.git存储库现在很大,尽管主要项目文件重量大概在兆左右)。我现在该如何摆脱这种膨胀?



非常感谢

解决方案

您可以尝试并按照 GitHub指南删除敏感数据


用户不时意外地将诸如密码或密钥之类的数据放入git仓库中。虽然您可以使用 git rm 删除文件,但它仍将位于回购的历史记录中。幸运的是,git可以非常简单地从整个repo历史记录中删除文件。



I know there's a million similar questions already, but I'm not sure they apply. I am new to git, and have a project hosted on github. I accidentally added some big log files to the repository. When I noticed it, I git rm-ed them and then commit-ted the changes. That seems to have done the job, in that when I clone the repository, I get only the files I wanted (source code). However, the cloning now takes forever, because, I assume, git is still downloading those log files for some reason (the .git repository is now huge, although the main project files weigh a meg or so). How can I get rid of that bloat now?

Thanks a lot

解决方案

You could try and follow the GitHub guide "remove sensitive data"

From time to time users accidentally commit data like passwords or keys into a git repo. While you can use git rm to remove the file, it will still be in the repo’s history. Fortunately, git makes it fairly simple to remove the file from the entire repo history.

这篇关于git - 从存储库中删除文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆