Skip to content

Instantly share code, notes, and snippets.

@kha-dinh
Created August 23, 2025 08:32
Show Gist options
  • Select an option

  • Save kha-dinh/6a6b6e9782fa4e373edeadddcd111ac6 to your computer and use it in GitHub Desktop.

Select an option

Save kha-dinh/6a6b6e9782fa4e373edeadddcd111ac6 to your computer and use it in GitHub Desktop.
Push very large repo with millions of commits (e.g., Linux) to github in steps. This overcome Github's 2GB limit.
#!/bin/bash ╭───────────  Line Numbers ────────────╮
BR=main
mapfile -t COMMITS < <(git rev-list --reverse --first-parent "$BR")
STEP=10000
for ((i = $STEP - 1; i < ${#COMMITS[@]}; i += STEP)); do
│ git push origin "${COMMITS[$i]}:refs/heads/main"
done
# Final push to bring remote to tip
git push origin "$BR:refs/heads/main"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment