简体   繁体   English

减少Bitbucket上的回购大小

[英]Reduce Repo Size on Bitbucket

I've realised my repo is coming in at just over 1GB, it seems my .git folder weighs in at 800MB. 我已经知道我的存储库即将超过1GB,看来我的.git文件夹重达800MB。 Why is this and what are the right ways to go about reducing this? 为什么会这样?减少这种情况的正确方法是什么?

Any help is appreciated. 任何帮助表示赞赏。 Thanks in advance! 提前致谢!

Your .git folder is bloated somehow, most likely due to git history or old assets: 您的.git文件夹因某种原因肿,很可能是由于git历史记录或旧资产:

Source: http://blogs.atlassian.com/2014/05/handle-big-repositories-git/ 资料来源: http : //blogs.atlassian.com/2014/05/handle-big-repositories-git/

  • They accumulate a very very long history (the project grows over a very long period of time and the baggage accumulates). 他们积累了非常长的历史(该项目在很长一段时间内不断发展,行李也不断积累)。
  • They include huge binary assets that need to be tracked and paired together with code. 它们包括巨大的二进制资产,需要与代码一起跟踪和配对。
  • Both of the above. 以上两者。

Here are some ways to remedy it: 以下是一些补救方法:

Shadow Clone Method 阴影克隆方法

Run git clone --depth <# of commits of history> <remote-url> . 运行git clone --depth <# of commits of history> <remote-url>

Filter-branch Method for large binary files or old assets like old PSDs 大型二进制文件或旧资产(如旧PSD)的过滤分支方法

Run something like git filter-branch --tree-filter 'rm -rf /path/to/spurious/asset/folder' HEAD . 运行类似git filter-branch --tree-filter 'rm -rf /path/to/spurious/asset/folder' HEAD东西。 Beware filter-branch can rewrite the history of your commits, thus others who have an older version of your repository will need to clone it again. 请注意filter-branch可以重写提交的历史记录,因此拥有较旧版本存储库的其他人将需要再次克隆它。 Warn your coworkers before you do this method! 在执行此方法之前,请警告您的同事!

There are more methods and alternative ways in the atlassian link above. 上面的地图集链接中有更多方法和替代方法。

EDIT: Make sure to create a backup repo of your original repo just in case! 编辑:确保以防万一,创建您原始回购的备份回购!

Instead of using git filter-branch manually, I highly recommend using the BFG ( https://rtyley.github.io/bfg-repo-cleaner/ ), since it is much faster and can help you get rid of larger files. 我强烈建议您使用BFG( https://rtyley.github.io/bfg-repo-cleaner/ ),而不是手动使用git filter-branch ,因为它速度更快,并且可以帮助您摆脱较大的文件。 The instructions on that page are very easy to follow. 该页面上的说明非常容易遵循。

However, note that the BFG removes large files from your .git history only if they are NOT currently committed to your repo. 但是,请注意,仅当BFG当前未提交给您的存储库时,BFG才会从他们的.git历史记录中删除它们。 Before you use the BFG, you should 在使用BFG之前,您应该

git rm --cached FILENAME

any large files (like large zips as you mentioned above). 任何大文件(例如您上面提到的大zip)。 If you don't need them anymore, you can just delete them completely. 如果您不再需要它们,则可以将其完全删除。 And remember to add *.zip to your .gitignore! 并记住将*.zip添加到您的.gitignore中!

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

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