Last active
November 19, 2024 17:21
-
-
Save piki/10d57cda6d5b25744fdeefb56b421fe4 to your computer and use it in GitHub Desktop.
Script to push (mirror) a large repo to GitHub
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
#!/bin/bash -ex | |
# | |
# Push the current repository to GitHub, in small enough chunks that it | |
# won't exceed the pack-size limit | |
# Commit to start with, counting from the oldest. If the process fails, | |
# you can change this variable to restart from where it failed. | |
START_COMMIT=1000 | |
# Number of commits to push at a time, counting from the oldest. If a | |
# push fails because the pack file is too big, try using a smaller number. | |
COMMIT_STEP=1000 | |
git log --pretty=%H | ruby -e 'puts ARGF.each_line.to_a.reverse' > commits | |
COMMIT_COUNT=$(wc -l commits | cut -d' ' -f1) | |
for i in `seq $START_COMMIT $COMMIT_STEP $COMMIT_COUNT`; do | |
echo ====== $i | |
COMMIT=$(git show $(head -$i commits | tail -1) | head -1 | cut -d' ' -f2) | |
git tag -d foo || true | |
git tag foo $COMMIT | |
git push -f origin foo | |
done | |
git tag -d foo | |
git push origin HEAD | |
git push --mirror |
@mejuliver Is the repository you're pushing a mirror of something else? You can run
git config remote.origin.mirror
to find out. If it's true, you need to rungit config --unset remote.origin.mirror
to set it not to be.You don't seem to be running the script with
bash -ex
that's in the#!
line. If you do, it will show each command as it runs and will stop at the first error, which is also helpful for debugging.
using this git config remote.origin.mirror
returns true so its a mirror repo
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@mejuliver Is the repository you're pushing a mirror of something else? You can run
git config remote.origin.mirror
to find out. If it's true, you need to rungit config --unset remote.origin.mirror
to set it not to be.You don't seem to be running the script with
bash -ex
that's in the#!
line. If you do, it will show each command as it runs and will stop at the first error, which is also helpful for debugging.