How to resize the remote repository without deleting all the commit history?

最后都变了- 提交于 2019-12-25 04:24:10

问题


There are several very related question already on stackoverflow (a few are linked below) but I could not solve my particular problem.

I share a repository with Co-workers who have pushed huge datafiles/images that increased the size of the remote repository up to 14 GB. Later on, these files got deleted using just rm filename which resized the local repositories to a reasonable size. However, when I check online, the repository's size is still 14 GB.

What I tried to reduce the repositories size is what is suggested here:

git reflog expire --expire=now --all
git gc --aggressive --prune=now

but that only affected my local repository's size.

The answers here did not help either since the files were not deleted on my own computer but on the Co-workers' ones.

What I have not tried yet, but which might work is to delete all the commit history as described here . However, I would actually keep all the commit history and just get rid of all the garbage created by rm filename on machines that are not my own.

Is there any solution to this (getting rid of garbage created on other local machines to decrease the size of the remote repository) without removing all the commit history?

EDIT:

In @torek's link in the comments, I found a command to get rid of commits related to a certain file. I then tried to get rid of all commits that are about images e.g. .png. I used the following command:

git filter-branch --tree-filter 'rm -f *.png' HEAD

However, I then get the message:

WARNING: Ref 'refs/heads/master' is unchanged

How would I use it correctly?

来源:https://stackoverflow.com/questions/40525675/how-to-resize-the-remote-repository-without-deleting-all-the-commit-history

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!