Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git push --mirror gives "failed to push some refs"

Tags:

git

I am trying to create a script that can mirror my git repository to another repository. Everything goes fine, but it it keeps saying

[remote rejected] refs/pull/xx/head -> refs/pull/xx/head (The current action can only be performed by the system.)

The repository is cloned to a folder on my computer, and then pushed to another git. All files and history is cloned and pushed as it should, but this "error" keeps coming up. What can i do?

enter image description here

This is my script

git clone --mirror https://path1.com/_git/fredagsproject1
cd fredagsproject1.git
git remote set-url --push origin https://path2.com/_git/fredagsproject2
git push --mirror
like image 496
Englund0110 Avatar asked Oct 06 '17 10:10

Englund0110


People also ask

How do I fix error failed to push some refs to?

We can fix the error: failed to push some refs to [remote repo] error in Git using the git pull origin [branch] or git pull --rebase origin [branch] commands. In most cases, the latter fixes the error.

Can not push ref to remote?

The Error Message The error: failed to push some refs to remote git error occurs when new changes are pushed to the repository on version control not yet made it to your local repository. This could happen when you are working with someone on one project and simultaneously push to a branch.

Which error would you get if you try to push master branch changes to a remote repository?

The error message error: refusing to update checked out branch: refs/heads/master is emitted by the remote repository and it means you're trying to push code to remote non-bare repository that has different code currently checked out in the working directory.

How do you set upstream?

The easiest way to set the upstream branch is to use the “git push” command with the “-u” option for upstream branch. Alternatively, you can use the “–set-upstream” option that is equivalent to the “-u” option.


1 Answers

When you run git push, you have your Git call up another Git over the Internet-phone. Your Git hands their Git some objects (commits and the like), and then sends their Git a pile of requests:

  • please set refs/heads/branch to point to commit 1234567...
  • please set refs/tags/v1.2 to point to annotated tag object fedcba9...

and the like.

Using git push --mirror tells your Git to ask their Git to set every name that you have, using exactly the same name in the request. As the image shows (and you've copied to a text line), many of these names have the form:

refs/pull/xx/head

for some two-digit xx sequence.

Their Git is simply saying No: I refuse to set that name.

You can try adding --force, which tells your Git to send a command—set these names!—instead of a polite request, please set these names, but take a look at the reason that their Git returned along with the refusal:

The current action can only be performed by the system.

That seems to say: Hands off this name! I reserve it for my use, how dare you ask me to change my refs/pull/73/head! In which case the command form (as opposed to the polite request form) is likely to be refused as well.

Note that ref-names of the form refs/pull/number/head and refs/pull/number/merge are used internally by, among others, GitHub for its management of pull requests. It's likely that you should not even attempt to set these names—so if your attempts are failing, that's probably a good thing.

like image 131
torek Avatar answered Sep 23 '22 19:09

torek