28

I cloned a repository from a github enterprise remote with the option "--mirror".

I'd like to push that repo in another remote repository but i've the following error:

>     ! [remote failure]        XXXX-7342f50b84fbfff3a2bbdcf81481dbcb2d88e5cd -> XXXX-7342f50b84fbfff3a2bbdcf81481dbcb2d88e5cd (remote failed to report status)
>     error: failed to push some refs to 'git@github.ZZZZ.com:XXXX/YYYY.git'
>     Branch master set up to track remote branch master from origin.
Bertrand
  • 994
  • 9
  • 23

6 Answers6

40

Running git gcresolved this for me. This will do some garbage-collecting housekeeping tasks which could be causing this issue.

Paul
  • 5,473
  • 1
  • 30
  • 37
2

I had this exact error with a very large (22Gb) mirror cloned repo that I was asked to import into our GitHub enterprise server.

git gc helped as it reduced the size of the repo to a mere 7Gb but I still could not push it because there were ~13k tags (and apparently every one was vital!) which were listed as errors in the same way as the OP reports.

The solution is to push the tags in smaller blocks e.g.

git push refs/tags/tag-2015* git@my_server:my_org/my_repo

You can put this into a loop and push all the tags in blocks e.g.

for n in {15..20}; do git push refs/tags/tag-20${n}* git@my_server:my_org/my_repo; done

Now when you do the original push --mirror those tags will already be present on the remote and you will not get the error.

Before getting to that I also pushed the branches in a similar way but as that didn't solve the issue I don't think it mattered. However incase it was relevant this is how you switch to each branch in a bare repo and push it.

git branch -a --format "%(refname)" | xargs -i bash -c "git symbolic-ref HEAD {} && git push git@my_server:my_org/my_repo"

This may be a myth but the reason I was given for this error is that git has some hidden limits deep within it. In this case there is a restriction on pushing tags where the whole operation must complete within 5 minutes. Hence breaking up the process works.

Martin
  • 2,316
  • 1
  • 28
  • 33
  • 1
    I had to reverse the order of the arguments from your example -- repo first, then refs. – Yamikuronue Mar 04 '21 at 18:19
  • Adding some info for an extra tough repo I had to handle for mirroring: First, I had to split into small batches all refs/heads/* Then I had to push also refs/tags/* At this point push --mirror still failed, however the hint was in seeing what next references are in the list of "failed to report status" and I understood there's another last area similar to refs/heads, which is refs/remotes/REMOTE_NAME/* After splitting this one into batches and pushing it too, the mirror was clean and successful. "--all" doesn't cover remote refs - same amount as refs/heads, "*:*" is like --mirror – Dani K Jul 22 '21 at 18:03
  • 1
    1. To loop over all refs you can use `git for-each-ref`, 2. to push multiple refs simultaneously you can specify multiple refs after `git push`, 3.to limit number of arguments you can use `-n` parameter for `xargs`. Combining all these together pushing 100 refs at once will look like `git for-each-ref --format='%(refname)' | xargs -n 100 git push origin` – Alex S. Feb 28 '23 at 21:39
1

It appears that i had to many references (~9000). Removing most of them fixed the issue

Bertrand
  • 994
  • 9
  • 23
1

I did a git pull --rebase branchname and then git push origin branchname

Sajitron
  • 346
  • 3
  • 10
1

I encountered this issue when pushing a repository generated with svn2git. Clearly there were no open PRs (brand new empty upstream repo), and repack and gc did not help. Size of the repo doesn't seem to be a factor. Here are some observations:

  1. When pushing to Github Enterprise (self-hosted): push --mirror works fine.
  2. When pushing to github.com, I get this issue. However:
  • git push --tags and git push --all work fine.
  • git push --mirror fails on either refs/backups/* or refs/replace/*

My conclusion is that this problem can arise for certain refs that github.com doesn't like, but --all --tags is good enough for my needs.

Akom
  • 1,484
  • 19
  • 25
  • Me too! I have no idea how to be sure my content is backed up, hopefully having all the branches is enough.. – Dani K Jul 22 '21 at 16:50
0

It looks like this error will also happen when Github is down (you can check Github's status here), as it is currently at the time I'm writing this. I'm getting a similar error, preceded by Internal Server Error:

davidcalhoun@Davids-MacBook-Pro hugo % git push
Enumerating objects: 11, done.
Counting objects: 100% (11/11), done.
Delta compression using up to 16 threads
Compressing objects: 100% (5/5), done.
Writing objects: 100% (6/6), 485 bytes | 485.00 KiB/s, done.
Total 6 (delta 4), reused 2 (delta 0)
remote: Resolving deltas: 100% (4/4), completed with 4 local objects.
remote: Internal Server Error
To github.com:davidcalhoun/davidbcalhoun.com.git
 ! [remote failure]    master -> master (remote failed to report status)
error: failed to push some refs to 'git@github.com:davidcalhoun/davidbcalhoun.com.git'
David Calhoun
  • 8,315
  • 4
  • 30
  • 23
  • 1
    Can confirm. Just panicked and removed the directories off of my machine to try and figure this out before I thought to check the status. – Ian Feb 27 '20 at 15:54