Created
February 28, 2024 13:35
-
-
Save ambrose40/33c86859b55df7a32bdfa74edf6a1e2b to your computer and use it in GitHub Desktop.
Batch push commits - partial push
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=2; 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
Author
Can be used with (after): https://gist.github.com/ambrose40/865e8f2f72b9d0b84c955c35a012420f
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
usage from console:
git partial-push origin main