问题
I have cleaned my repo with BFG Repo Cleaner using the following procedure:
$ git clone --mirror git://example.com/some-big-repo.git
$ java -jar bfg.jar --strip-biggest-blobs 500 some-big-repo.git
$ cd some-big-repo.git
$ git reflog expire --expire=now --all
$ git gc --prune=now --aggressive
$ git push
I can see that my local repo has shrunk with 1GB. Great. The problem that I'm having now and that I haven't been able to find any info on is that now I would like to also shrink the size of the GitHub-repo as well. How to achieve this?
git push
didn't work and I also tried git push origin --force --all
which gave me this error message: error: --all and --mirror are incompatible
回答1:
My advice: don't worry too much about what GitHub reports as the repo size. For various reasons it won't accurately reflect the 'true' size of the repo.
What you really care about is the answer to this question:
How big is this repo on my disk if I do a fresh clone of it from GitHub?
The amount of data you have to download to do a fresh clone of your repo, and the amount of space it takes up on your disk, are the things you really care about (and nearly identical quantities). Try doing a fresh clone and seeing how much data gets transferred and how much room it takes up on your disk. It should match the size of your shrunken repo.
The number reported in the GitHub console (ie at https://github.com/settings/repositories, or in the GitHub API) is not really important to you, which is fortunate, because it enjoys a liberated and somewhat drunken relationship with the more important figure above, due to the use of Git Alternates, and git gc
occurring only periodically on GitHub servers.
Side note: Bitbucket can also take time to update reported repo size.
Just because you ran git gc
locally on your repo, doesn't mean GitHub have run it on their copy of your repo yet, and so their copy of your repo will appear much bigger for a while, even though when you clone it, only the 'essential' information is sent, and so you receive the smaller repo that you desire.
Full disclosure: I'm the author of the BFG Repo-Cleaner.
回答2:
If it is possible:
- rename your current GitHub repo
- create a new one with the same name
- push again to your empty GitHub repo (
git push --mirror
) - check if the size warning persists in said new GitHub rpeo
回答3:
Push without the --all
flag, that is, do
git push origin --force
and that should take care of it.
EDIT: Improvising upon discussion in comments
- You can create a new repo on github,
push to it
cd repo_directory git remote add new_origin url/to/new/repo git push new_origin --mirror
- if things work out (no errors)
- rename the github repos (the original to a dummy name and the new one to original)
Drop the remote
new_origin
. Since the github repo url should be same after you have renamed stuff, the original entry for[origin]
in.git/config
should hold good, and you only need remove the new remote added.git remote rm new_origin
来源:https://stackoverflow.com/questions/25459123/how-to-update-shrink-the-size-of-my-github-repo-after-running-bfg-repo-cleaner