21

解决 git push:pack exceeds maximum allowed size 报错的问题

 1 year ago
source link: https://chegva.com/5658.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

解决 git push:pack exceeds maximum allowed size 报错的问题

前天github上有个仓库被dmca封掉了,不得不提工单申请解封处理一波 → Github仓库由于DMCA被封怎么办? 不过由于这个仓库时间比较久,大小有2.07GB,一次全部提交被限制报错了:remote: fatal: pack exceeds maximum allowed size (2.00 GiB),谷歌了一波,最后在网上找了个脚本解决了,内容如下:

# Adjust the following variables as necessary
REMOTE=origin
BRANCH=$(git rev-parse --abbrev-ref HEAD)
BATCH_SIZE=100
# check if the branch exists on the remote
if git show-ref --quiet --verify refs/remotes/$REMOTE/$BRANCH; then
# if so, only push the commits that are not on the remote already
range=$REMOTE/$BRANCH..HEAD
else
# else push all the commits
range=HEAD
fi
# count the number of commits to push
n=$(git log --first-parent --format=format:x $range | wc -l)
# push each batch
for in $(seq $n -$BATCH_SIZE 1); do
# get the hash of the commit to push
h=$(git log --first-parent --reverse --format=format:%H --skip $i -n1)
echo "Pushing $h..."
git push $REMOTE $h:refs/heads/$BRANCH
done
# push the final partial batch
git push $REMOTE HEAD:refs/heads/$BRANCH

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK