! [remote rejected] errors after mirroring a git repository

后端 未结 4 552
暖寄归人
暖寄归人 2020-12-23 16:41

I\'m following this documentation: https://help.github.com/articles/duplicating-a-repository/

git clone --mirror https://github.com/exampleuser/repository-to         


        
相关标签:
4条回答
  • 2020-12-23 17:28

    instead of

    git clone --mirror

    use

    git clone --bare

    instructions

    0 讨论(0)
  • 2020-12-23 17:30

    As mentioned in this issue, that happens when you mirror a GitHub repo which has pull requests made to it.

    The refs beginning 'refs/pull' are synthetic read-only refs created by GitHub - you can't update (and therefore 'clean') them, because they reflect branches that may well actually come from other repositories - ones that submitted pull-requests to you.

    So, while you've pushed all your real refs, the pull requests don't get updated

    You would need to mirror a GitHub repo without their pull requests.

    Simply replace the catch-all refspec above with two more specific specs to just include all heads and tags, but not the pulls, and all the remote pull refs will no longer make it into your bare mirror:

    fetch = +refs/heads/*:refs/heads/*
    fetch = +refs/tags/*:refs/tags/*
    fetch = +refs/change/*:refs/change/*
    
    0 讨论(0)
  • 2020-12-23 17:35

    (I wanted this to be a comment, but not enough reputation)

    Based on @VonC's answer, this sounds like a non-problem.

    So, while you've pushed all your real refs, the pull requests don't get updated

    I see two scenarios in which you want to duplicate your repository.

    1. You want a backup/copy of a repo that you have full control over.
    2. You're modifying the history of a repo and you need a backup locally in case you need to undo your changes.

    In either case, it seems like git clone --mirror is your safest option because even if you see errors in your push, all of the non-pull request related content was successfully pushed, which takes care of scenario 1. For scenario 2, you'd want those pull request references as part of your backup.

    0 讨论(0)
  • 2020-12-23 17:41

    Found working and simple solutions there https://www.metaltoad.com/blog/git-push-all-branches-new-remote

    git push newremote refs/remotes/oldremote/*:refs/heads/*
    

    or

    git push newremote refs/remotes/oldremote/features/*:refs/heads/features/*
    
    0 讨论(0)
提交回复
热议问题