0

I am trying to clone --mirror a cloud source repository and push it to gitlab as a backup mechanism. When I first tried to do it, there was no error. However, when I tested it again after pushing some changes to the cloud source repo, I am getting the below error.

! [remote rejected] origin/feature -> origin/feature (deny updating a hidden ref)  
! [remote rejected] origin/master -> origin/master (deny updating a hidden ref)  
! [remote rejected] origin/test -> origin/test (deny updating a hidden ref) error: failed to push some refs to 'https://gitlab.com/xxxx.git'

Below is the build config file that is triggered every time a backup needs to be taken.

    steps:
  - name: gcr.io/cloud-builders/git
    args:
      - clone
      - '--mirror'
      - 'https://source.developers.google.com/cloud-source-repo'
  - name: gcr.io/cloud-builders/git
    args:
      - fetch
      - '--unshallow'
  - name: gcr.io/cloud-builders/git
    args:
      - '-c'
      - ls
      - cd backup-to-gitlab.git
    entrypoint: bash
  - name: gcr.io/cloud-builders/git
    args:
      - remote
      - set-url
      - '--push'
      - origin
      - >-
        https://xxx:password@gitlab.com/xxxx.git
  - name: gcr.io/cloud-builders/git
    args:
      - push
      - '--mirror'
  - name: gcr.io/cloud-builders/git
    args:
      - '-c'
      - ''
      - cd ..
      - rm
      - '-rf'
      - backup-to-gitlab.git
    entrypoint: bash
Rutu Patel
  • 21
  • 1
  • 4
  • 1
    Does this answer your question? [! \[remote rejected\] errors after mirroring a git repository](https://stackoverflow.com/questions/34265266/remote-rejected-errors-after-mirroring-a-git-repository) – Martin Zeitler Dec 14 '21 at 18:33
  • No, not really. I haven't made any pull request. And the error in the question you sent is related to having a pull request. – Rutu Patel Dec 14 '21 at 18:41
  • 1
    The linked question here does refer to pull requests specifically, but the issue is generic: a Git server may have "protected" name-space entries, and in this case you're attempting to have the GitLab Git server set its `origin/*` entries and those are protected. So it is the same problem, in the end. (The error message is misleading: it's not a *hidden* ref.) – torek Dec 14 '21 at 19:32
  • 1
    If you strip out the `origin/*` entries and any other hidden/protected ones, you should be able to do your mirror-force-push. Or you can use the method outlined in VonC's answer there: don't do a full mirror clone, do a selective mirror clone so that you only *get* the refs you intend to push. – torek Dec 14 '21 at 19:35

0 Answers0