简体   繁体   English

Git:覆盖或擦除存储库中的大文件(归档)?

[英]Git: overwrite or wipe large files (archives) from repository?

I have a repository that uses 3rd-party code that currently is downloaded and compiled using a shell script. 我有一个存储库,该存储库使用当前使用Shell脚本下载和编译的第3方代码。 This works, but sometimes mirrors are slow or unreachable. 这可行,但是有时镜像很慢或无法到达。 It would be easier for me (since 3rd-party code are only OpenSource projects) to bundle it with my code. 对我来说,将它与我的代码捆绑起来会更容易(因为第三方代码只是OpenSource项目)。

However, I do not want my git repository to become huge over time (like it normally does, when you include large binary files that get stored each time you update them). 但是,我不希望我的git存储库随着时间的推移而变得庞大(就像通常那样,当您包含每次更新它们都会存储的大型二进制文件时)。

Is there any way to wipe .tar.gz (or similar) archives from a git repository? 有什么办法可以从git仓库中删除.tar.gz(或类似文件)档案?

Or could I somehow overwrite foo.tar.gz once it gets outdated? 还是一旦过时我就可以覆盖foo.tar.gz吗? So that it only consumes the memory the most recent version uses (and therefore drops older revisions of the file)? 这样就只消耗最新版本使用的内存(并因此删除文件的较早修订版)?

Is there any way to wipe .tar.gz (or similar) archives from a git repository? 有什么办法可以从git仓库中删除.tar.gz(或类似文件)档案?

How to remove big files from the repository

There are few ways to do it: 有几种方法可以做到:

  • You can use git filter-branch . 您可以使用git filter-branch

  • BFG Repo-Cleaner BFG回购清洁剂

    BFG Repo-Cleaner

    An alternative to git-filter-branch. git-filter-branch的替代方法。

    The BFG is a simpler, faster alternative to git-filter-branch for cleansing bad data out of your Git repository history: BFG是git-filter-branch的一种更简单,更快的替代方法,用于从Git存储库历史记录中清除不良数据

    Removing Crazy Big Files 删除疯狂的大文件
    Removing Passwords, Credentials & other Private data 删除密码,凭据和其他私人数据

    Examples (from the official site) 示例(来自官方网站)

    In all these examples bfg is an alias for java -jar bfg.jar. 在所有这些示例中,bfg是java -jar bfg.jar的别名。

      # Delete all files named 'id_rsa' or 'id_dsa' : bfg --delete-files id_{dsa,rsa} my-repo.git 
  • GIT LFS (large file storage) GIT LFS(大文件存储)


    在此处输入图片说明

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

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