Last active
October 21, 2025 00:06
-
-
Save RubenKelevra/5efe0cf240dc02226784d4fd64f8ec6a to your computer and use it in GitHub Desktop.
Github only accepts pushes up to 2 GB as they are bundled into a single pack - this allows for a partial push via `git partial-push origin branchname` after placing it into .gitconfig. Error message"remote: fatal: pack exceeds maximum allowed size (2.00 GiB) error: remote unpack failed: index-pack abnormal exit"
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [alias] | |
| partial-push = "!sh -c | |
| 'REMOTE=$0;BRANCH=$1;BATCH_SIZE=100; | |
| if git show-ref --quiet --verify refs/remotes/$REMOTE/$BRANCH; then | |
| range=$REMOTE/$BRANCH..HEAD; | |
| else | |
| range=HEAD; | |
| fi; | |
| n=$(git log --first-parent --format=format:x $range | wc -l); | |
| echo "Have to push $n packages in range of $range"; | |
| for i in $(seq $n -$BATCH_SIZE 1); do | |
| h=$(git log --first-parent --reverse --format=format:%H --skip $i -n1); | |
| echo "Pushing $h..."; | |
| git push $REMOTE ${h}:refs/heads/$BRANCH; | |
| done; | |
| git push $REMOTE HEAD:refs/heads/$BRANCH' | |
| " | |
| # Author: Crt Mori on stackoverflow.com | |
| # Source: https://stackoverflow.com/a/72977369 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If anyone gets a
fatal: bad config line # in file ~/.gitconfigor similar error, I had to update the code in this gist to be the following (I also added some additional comments):Essentially just needed to make the alias be on a single line (and is actually how the StackOverflow link in the comment actually initially provided it.) I also implemented the patch suggested in the comments in that StackOverflow answer (replace
--format=format:xwith--oneline) to avoid it miscounting commits and/or keep the output more condensed. 👍That said... this just got rid of that upfront syntax error I encountered. It's in the process of running partial-push now so I'm waiting to find out if it successfully got around the
remote: fatal: pack exceeds maximum allowed size (2.00 GiB)error (while it seems this actually doesn't fix things for a single commit being larger than 2GB so I'll just make smaller commits for my specific situation [while this will still be helpful to push those then-smaller commits in one go.])