githubgit-pushmirroring

Push --mirror from bare repo to empty GitHub repo fails


There is an repo in GitHub Enterprise with 1611 branches. I try to create an backup via bear repo and push --mirror (in comply with doc: https://docs.github.com/en/repositories/creating-and-managing-repositories/duplicating-a-repository). Literally this:

git clone --bare https://github.myorg.com/EXAMPLE-USER/OLD-REPOSITORY.git

cd OLD-REPOSITORY

git push --mirror https://github.myorg.com/EXAMPLE-USER/NEW-REPOSITORY.git

Push ends up with error and leaves remote repo intact:

Enumerating objects: 56995, done.
Counting objects: 100% (34840/34840), done.
Delta compression using up to 12 threads
Compressing objects: 100% (730/730), done.
Writing objects: 100% (56995/56995), 230.72 MiB | 3.56 MiB/s, done.
Total 56995 (delta 34303), reused 34110 (delta 34110), pack-reused 22155
remote: Resolving deltas: 100% (44324/44324), completed with 8890 local objects.
remote: fatal error in commit_refs
To https://github.myorg.com/EXAMPLE-USER/NEW-REPOSITORY.git
 ! [remote rejected]     Release/9.10.4 -> Release/9.10.4 (failure)
 ! [remote rejected]     TFS_C60113 -> TFS_C60113 (failure)
 ! [remote rejected]     TFS_C81349 -> TFS_C81349 (failure)
 ! [remote rejected]     release/9.10.4 -> release/9.10.4 (failure)
 ! [remote rejected]     Created_9.8_On_TFS -> Created_9.8_On_TFS (failure)
 ! [remote rejected]     TFS_C53824 -> TFS_C53824 (failure)
 ! [remote rejected]     TFS_C53825 -> TFS_C53825 (failure)
 ! [remote rejected]     TFS_C53826 -> TFS_C53826 (failure)
...
 ! [remote rejected]     archive/2024/patch/adobe -> archive/2024/patch/adobe (failure)
 ! [remote rejected]     archive/2022/DELETE_MASTER -> archive/2022/DELETE_MASTER (failure)
error: failed to push some refs to 'https://github.myorg.com/EXAMPLE-USER/NEW-REPOSITORY.git'

Push of either branches or tags one by one works with no issues. What do I miss? Is there something I can tweak to get it working? Is there the way to get additional details in term of the root-cause?


Solution

  • Didn't find the description of the root-cause. The workable workaround happened to be push to remote branches in bundles, followed by git push --mirror:

    git clone --mirror github.myorg.com/EXAMPLE-USER/REPOSITORY.git 
    git remote add ssh_mirror github.myorg.com/EXAMPLE-USER/NEW-REPOSITORY.git git push ssh_mirror refs/heads/archive/2024/A* 
    git push ssh_mirror refs/heads/archive/2024/B* 
    .... 
    git push ssh_mirror refs/heads/archive/2024/z* 
    git push --mirror ssh_mirror