I'm not very experienced with git but set up a public mirror of a private repository a few months ago and now want to update it to the current status of the private repository.
I'm following the instructions here and pretty sure this is what I followed when initially creating the mirror:
However, this time when I execute the following:
git clone --mirror https://github.com/billtubbs/process-observers.git
cd process-observers.git/
git push --mirror https://github.com/billtubbs/ml-obs.git
I get
Enumerating objects: 991, done.
Counting objects: 100% (991/991), done.
Delta compression using up to 8 threads
Compressing objects: 100% (261/261), done.
Writing objects: 100% (938/938), 2.27 MiB | 2.67 MiB/s, done.
Total 938 (delta 724), reused 889 (delta 677)
remote: Resolving deltas: 100% (724/724), completed with 40 local objects.
To https://github.com/billtubbs/ml-obs.git
74c80ea...9ff3e6b main -> main (forced update)
dce6fcc..9ff3e6b origin/main -> origin/main
* [new branch] origin/HEAD -> origin/HEAD
! [remote rejected] refs/pull/1/head -> refs/pull/1/head (deny updating a hidden ref)
! [remote rejected] refs/pull/2/head -> refs/pull/2/head (deny updating a hidden ref)
error: failed to push some refs to 'https://github.com/billtubbs/ml-obs.git'
What does this mean "failed to push some refs to ..."?
All the files seem to be updated.
CodePudding user response:
Nothing has actually gone wrong in terms of copying the commits. What's happened here is that your mirror clone included all the pull request commits available in the original repository;1 your subsequent git push
tried to send those commits and the names used to find them to the new repository on GitHub, but GitHub tightly control those names, so they rejected the attempt to create such names.
The original PR commits are lost from the new copy, but this will always be the case when using this method to copy a GitHub repository.
One thing that did go slightly wrong—this is not too serious—is that you've created two bogus branch names in the new GitHub repository:
dce6fcc..9ff3e6b origin/main -> origin/main * [new branch] origin/HEAD -> origin/HEAD
The first line shows that you've update a branch name origin/main
in the GitHub repository, and you don't want that. (It was already there, for whatever reason, probably created by your original sequence.) The second line shows that you created a new branch name origin/HEAD
in the GitHub repository.
While there's nothing actually broken by having such a name, these names are extremely confusing to users, who wind up with origin/origin/main
and origin/origin/HEAD
remote-tracking names in their clones. So it's a good idea to delete these two branch names from the GitHub repository, so that people cloning it don't get these weird, difficult-to-use, difficult-to-deal-with names.
1As flotho answered, the GitHub instructions say to use git clone --bare
, not git clone --mirror
. Using --bare
avoids copying these extra names. The extra-name-copying wasn't actually harmful though, except in terms of causing the subsequent complaints.
CodePudding user response:
I think you might have made a small mistake following the docs.
Try to change the option --mirror
to --bare
in the git clone
command.
Just like is written in the docs:
- Create a bare clone of the repository.
$ git clone --bare https://github.com/EXAMPLE-USER/OLD-REPOSITORY.git