以下压缩包:
./resources/godot.tar.gz
./resources/godot-haskell-gdwlroots.tar.gz
一直使我的git repo变得非常大(即150MB以上)。我尝试使用以下命令移动它们:
pruneTarballs() {
git filter-branch --index-filter "git rm -rf --cached --ignore-unmatch ./resources/godot-haskell-gdwlroots.tar.gz" HEAD
git filter-branch -f --index-filter "git rm -rf --cached --ignore-unmatch ./resources/godot.tar.gz" HEAD
git push origin --all --force
git push origin --tags --force
}
但它对存储库的大小(仍然超过150MB)没有任何影响!然后我跑了:
# Ensure all old refs are fully removed
rm -Rf .git/logs .git/refs/original
# Perform a garbage collection to remove commits with no refs
git gc --prune=all --aggressive
,它的大小也没有降低到150MB以下。供参考,这是仓库的当前分布:
$ du -sch .[!.]* * | sort -h
4.0K Consent.md
4.0K default_env.tres
4.0K export_presets.cfg
4.0K .gitignore
4.0K .gitmodules
4.0K icon.png
4.0K icon.png.import
4.0K Makefile
4.0K project.godot
8.0K README.org
16K utils
2.3M doc
3.0M addons
154M .git
159M total
编辑:然后我从CHECKLIST FOR SHRINKING A RESPOSITORY跑了:
git reflog expire --expire=now --all
git gc --prune=now
,现在.git
的大小为65MB(这似乎仍然很高,但比原来的150MB小得多)。收缩仓库的清单也建议:
在调用git-filter-branch时使用
--tag-name-filter cat -- --all
但是尚不清楚如何相应地修改我原来的命令filter-branch命令:
git filter-branch --index-filter "git rm -rf --cached --ignore-unmatch ./resources/godot-haskell-gdwlroots.tar.gz" HEAD
git filter-branch -f --index-filter "git rm -rf --cached --ignore-unmatch ./resources/godot.tar.gz" HEAD
我还参加了(根据检查清单的建议):
git for-each-ref --format="%(refname)" refs/original/ | xargs -n 1 git update-ref -d # This parsed as an incorrect command by git
,但是它被git解析为不正确的命令,因此没有执行任何操作。有人有建议吗?
编辑2:现在,在提交并尝试推送到GitHub后,我得到:
$ git push origin --all --force
Enumerating objects: 9, done.
Counting objects: 100% (9/9), done.
Delta compression using up to 8 threads
Compressing objects: 100% (5/5), done.
Writing objects: 100% (5/5), 446 bytes | 446.00 KiB/s, done.
Total 5 (delta 4), reused 0 (delta 0)
remote: error: refusing to update checked out branch: refs/heads/gdwlroots
remote: error: By default, updating the current branch in a non-bare repository
remote: is denied, because it will make the index and work tree inconsistent
remote: with what you pushed, and will require 'git reset --hard' to match
remote: the work tree to HEAD.
remote:
remote: You can set the 'receive.denyCurrentBranch' configuration variable
remote: to 'ignore' or 'warn' in the remote repository to allow pushing into
remote: its current branch; however, this is not recommended unless you
remote: arranged to update its work tree to match what you pushed in some
remote: other way.
remote:
remote: To squelch this message and still keep the default behaviour, set
remote: 'receive.denyCurrentBranch' configuration variable to 'refuse'.
To /home/george/./SimulaMakeGit
! [remote rejected] gdwlroots -> gdwlroots (branch is currently checked out)
error: failed to push some refs to '/path/to/my/repo.git'