Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git push --mirror without pull refs

Tags:

git

bash

github

I'm migrating one git repo to another. To do this I'm using the --mirror flag for both the clone and push operations.

This works, except for a failure at the end, causing my bash script to fail, which appears isolated to pull requests:

! [remote rejected] refs/pull/1/head -> refs/pull/1/head (The current action can only be performed by the system.) ! [remote rejected] refs/pull/1/merge -> refs/pull/1/merge (The current action can only be performed by the system.) ! [remote rejected] refs/pull/2/head -> refs/pull/2/head (The current action can only be performed by the system.) ! [remote rejected] refs/pull/3/head -> refs/pull/3/head (The current action can only be performed by the system.)

Is it necessary to migrate pull requests?

How can I omit the pull requests when I do git push --mirror?

I've seen references to modifying config files, but I'd prefer to handle it at the CLI if at all possible.

like image 941
Mark Richman Avatar asked Dec 12 '17 15:12

Mark Richman


People also ask

What is GIT mirror command?

Git mirroring is when a mirror copies the refs & the remote-tracking branches. It's supposed to be a functionally identical copy that is interchangeable with the original.

What is git clone mirror?

A clone copies the refs from the remote and stuffs them into a subdirectory named 'these are the refs that the remote has'. A mirror copies the refs from the remote and puts them into its own top level - it replaces its own refs with those of the remote.


1 Answers

Using --mirror directs Git to copy all references, as if by the refspec +refs/*:refs/*. (With git clone it sets up a fetch mirror as well: a bare clone whose default refspec is this same +refs/*:refs/*, with prune enabled by default.)

As you have seen, some Git servers refuse even forced updates to some references. In particular, GitHub reserves the refs/pull/ namespace for its own purposes.

Is it necessary to migrate pull requests?

As far as I know, it's not even possible to do this on GitHub (though of course the GitHub folks might be able to do it from their end).

How can I omit the pull requests when I do git push --mirror?

I think the simplest method would be to delete them after the git clone --mirror step:

git for-each-ref --format 'delete %(refname)' refs/pull | git update-ref --stdin

but you could also explicitly push the references you care about, which probably are just those under refs/heads/ and refs/tags/, and maybe refs/replace/ and/or refs/notes/.

like image 50
torek Avatar answered Sep 29 '22 06:09

torek