How do I migrate a git repo to github with many of tags and branches?

377 views Asked by At

Hi all I'm currently attempt to migrate a git repo from bitbucket to github.com with >21,000 tags and >800 branches and running into the following problems.

  • The git push --mirror origin command fails with an internal server error.
    • However individual branches can be pushed one at a time successfully. Example git push origin develop will push the develop branch that empty directory.
  • There is no files larger than 50MB which would require large file storage. We previously ran bfg to clean a few files that were not needed in the git history.

We can do some cleanup to limit branches down to about 500 total (including release branches) but all tags are required for internal packaging.

Is there a way to run git push --mirror origin without github having an internal server error?

Notes The http protocol set to 500MB so things are written faster. SSH will write very slowly so I prefer HTTP protocol unless someone has a suggestion on how to increase SSH transfer speed.

Git config settings to speedup https (otherwise upload takes about 25-45mins at 214KiB/s git config --global http.postBuffer 524288000

Pseudo code with https

git clone --mirror <https://git.bitbucket.url>
git remote set-url origin <https://github.com.url>
git push --mirror

Pushing to https://github.com/<USER_ID>/YOUR_APP.git
Enumerating objects: 308119, done.
Counting objects: 100% (308119/308119), done.
Delta compression using up to 12 threads
Compressing objects: 100% (91394/91394), done.
Writing objects: 100% (308119/308119), 350.82 MiB | 529.07 MiB/s, done.
Total 308119 (delta 205766), reused 308103 (delta 205750), pack-reused 0
POST git-receive-pack (370558594 bytes)
remote: Resolving deltas: 100% (205766/205766), done.
remote: Internal Server Error
Everything up-to-date

When using the same method above but with SSH I get a much slower upload (~200-400 KiB/s) but the errors show up for each tag and branch. (see below)

[remote failure]        example_branch_v2 -> example_branch_v2 (remote failed to report status)

So far only way to push to github.com and perform this migration is to manually push each branch. If that's the only solution I'll need to write an iteration script.

Does anyone have experience with this before and had success with a config that would allow me to push the --mirror directly up to a new github.com repo?

Thanks!

1

There are 1 answers

0
VonC On

Iterate for each branch is the first approach indeed:

for branch in "$(git for-each-ref --format='%(refname:short)' refs/heads)"; do
    git push -u origin ${branch}
done

The only other approach was to transfer a bundle to the server, which is not possible here (github.com).