Merging two divergent repositories on different remotes












1















Me and my colleague set up a new repository on both GitHub and GitLab. All was nice, but due to a misunderstanding, he was pushing to GitHub and I was pushing to GitLab. We set up rep mirroring on GitLab but only one-way, which caused our repositories to diverge. Now, I'd like to merge them, and migrate to only GitLab, but when I did:



git remote add gitlab https://username@gitlab.com/username/rep.git
git push --mirror gitlab


I got the following error:



remote: GitLab: You are not allowed to force push code to a protected branch on this project
! [remote rejected] branch only on GitLab (pre-receive hook decline)
! [remote rejected] master -> master (pre-receive hook declined)
! [remote rejected] origin/HEAD -> origin/HEAD (deny updating a hidden ref)
! [remote rejected] origin/master -> origin/master (deny updating a hidden ref)
error: failed to push some refs to URL OF THE REP ON GITLAB


While I could just try to copy and paste the code to the repository on GitLab, I'd like to do it a clean way (if such a way even exists).










share|improve this question



























    1















    Me and my colleague set up a new repository on both GitHub and GitLab. All was nice, but due to a misunderstanding, he was pushing to GitHub and I was pushing to GitLab. We set up rep mirroring on GitLab but only one-way, which caused our repositories to diverge. Now, I'd like to merge them, and migrate to only GitLab, but when I did:



    git remote add gitlab https://username@gitlab.com/username/rep.git
    git push --mirror gitlab


    I got the following error:



    remote: GitLab: You are not allowed to force push code to a protected branch on this project
    ! [remote rejected] branch only on GitLab (pre-receive hook decline)
    ! [remote rejected] master -> master (pre-receive hook declined)
    ! [remote rejected] origin/HEAD -> origin/HEAD (deny updating a hidden ref)
    ! [remote rejected] origin/master -> origin/master (deny updating a hidden ref)
    error: failed to push some refs to URL OF THE REP ON GITLAB


    While I could just try to copy and paste the code to the repository on GitLab, I'd like to do it a clean way (if such a way even exists).










    share|improve this question

























      1












      1








      1








      Me and my colleague set up a new repository on both GitHub and GitLab. All was nice, but due to a misunderstanding, he was pushing to GitHub and I was pushing to GitLab. We set up rep mirroring on GitLab but only one-way, which caused our repositories to diverge. Now, I'd like to merge them, and migrate to only GitLab, but when I did:



      git remote add gitlab https://username@gitlab.com/username/rep.git
      git push --mirror gitlab


      I got the following error:



      remote: GitLab: You are not allowed to force push code to a protected branch on this project
      ! [remote rejected] branch only on GitLab (pre-receive hook decline)
      ! [remote rejected] master -> master (pre-receive hook declined)
      ! [remote rejected] origin/HEAD -> origin/HEAD (deny updating a hidden ref)
      ! [remote rejected] origin/master -> origin/master (deny updating a hidden ref)
      error: failed to push some refs to URL OF THE REP ON GITLAB


      While I could just try to copy and paste the code to the repository on GitLab, I'd like to do it a clean way (if such a way even exists).










      share|improve this question














      Me and my colleague set up a new repository on both GitHub and GitLab. All was nice, but due to a misunderstanding, he was pushing to GitHub and I was pushing to GitLab. We set up rep mirroring on GitLab but only one-way, which caused our repositories to diverge. Now, I'd like to merge them, and migrate to only GitLab, but when I did:



      git remote add gitlab https://username@gitlab.com/username/rep.git
      git push --mirror gitlab


      I got the following error:



      remote: GitLab: You are not allowed to force push code to a protected branch on this project
      ! [remote rejected] branch only on GitLab (pre-receive hook decline)
      ! [remote rejected] master -> master (pre-receive hook declined)
      ! [remote rejected] origin/HEAD -> origin/HEAD (deny updating a hidden ref)
      ! [remote rejected] origin/master -> origin/master (deny updating a hidden ref)
      error: failed to push some refs to URL OF THE REP ON GITLAB


      While I could just try to copy and paste the code to the repository on GitLab, I'd like to do it a clean way (if such a way even exists).







      git github merge repository gitlab






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Jan 1 at 12:18









      huB1erTi2huB1erTi2

      61




      61






















          1 Answer
          1






          active

          oldest

          votes


















          0














          Take a closer look at gitlab's error message: "You are not allowed to force push code to a protected branch on this project". By default, gitlab designates the master branch as "protected", and admins for the project may optionally designate other protected branches as well. So you need to find a way to avoid having to force-push master.



          This is not a situation I've personally encountered before, but the first thing I would try would be (after backing up my local repo, just in case!) to create a new branch off your local master, pull from gitlab and merge its master into yours, push back to gitlab (which should no longer require master to be a force-push), and then merge the new branch you created (your old master) into the gitlab master.



          Alternately, if your local repo is in exactly the state you want to be "current" in gitlab, there's also the option of deleting (or renaming) the project in gitlab, then creating a new one to replace it, based on your local copy. This would avoid having to (re-?)merge the two versions of the project and (unlike copy/pasting the content) would preserve all of the history, as your local repo knows it.






          share|improve this answer























            Your Answer








            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "3"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1389508%2fmerging-two-divergent-repositories-on-different-remotes%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            Take a closer look at gitlab's error message: "You are not allowed to force push code to a protected branch on this project". By default, gitlab designates the master branch as "protected", and admins for the project may optionally designate other protected branches as well. So you need to find a way to avoid having to force-push master.



            This is not a situation I've personally encountered before, but the first thing I would try would be (after backing up my local repo, just in case!) to create a new branch off your local master, pull from gitlab and merge its master into yours, push back to gitlab (which should no longer require master to be a force-push), and then merge the new branch you created (your old master) into the gitlab master.



            Alternately, if your local repo is in exactly the state you want to be "current" in gitlab, there's also the option of deleting (or renaming) the project in gitlab, then creating a new one to replace it, based on your local copy. This would avoid having to (re-?)merge the two versions of the project and (unlike copy/pasting the content) would preserve all of the history, as your local repo knows it.






            share|improve this answer




























              0














              Take a closer look at gitlab's error message: "You are not allowed to force push code to a protected branch on this project". By default, gitlab designates the master branch as "protected", and admins for the project may optionally designate other protected branches as well. So you need to find a way to avoid having to force-push master.



              This is not a situation I've personally encountered before, but the first thing I would try would be (after backing up my local repo, just in case!) to create a new branch off your local master, pull from gitlab and merge its master into yours, push back to gitlab (which should no longer require master to be a force-push), and then merge the new branch you created (your old master) into the gitlab master.



              Alternately, if your local repo is in exactly the state you want to be "current" in gitlab, there's also the option of deleting (or renaming) the project in gitlab, then creating a new one to replace it, based on your local copy. This would avoid having to (re-?)merge the two versions of the project and (unlike copy/pasting the content) would preserve all of the history, as your local repo knows it.






              share|improve this answer


























                0












                0








                0







                Take a closer look at gitlab's error message: "You are not allowed to force push code to a protected branch on this project". By default, gitlab designates the master branch as "protected", and admins for the project may optionally designate other protected branches as well. So you need to find a way to avoid having to force-push master.



                This is not a situation I've personally encountered before, but the first thing I would try would be (after backing up my local repo, just in case!) to create a new branch off your local master, pull from gitlab and merge its master into yours, push back to gitlab (which should no longer require master to be a force-push), and then merge the new branch you created (your old master) into the gitlab master.



                Alternately, if your local repo is in exactly the state you want to be "current" in gitlab, there's also the option of deleting (or renaming) the project in gitlab, then creating a new one to replace it, based on your local copy. This would avoid having to (re-?)merge the two versions of the project and (unlike copy/pasting the content) would preserve all of the history, as your local repo knows it.






                share|improve this answer













                Take a closer look at gitlab's error message: "You are not allowed to force push code to a protected branch on this project". By default, gitlab designates the master branch as "protected", and admins for the project may optionally designate other protected branches as well. So you need to find a way to avoid having to force-push master.



                This is not a situation I've personally encountered before, but the first thing I would try would be (after backing up my local repo, just in case!) to create a new branch off your local master, pull from gitlab and merge its master into yours, push back to gitlab (which should no longer require master to be a force-push), and then merge the new branch you created (your old master) into the gitlab master.



                Alternately, if your local repo is in exactly the state you want to be "current" in gitlab, there's also the option of deleting (or renaming) the project in gitlab, then creating a new one to replace it, based on your local copy. This would avoid having to (re-?)merge the two versions of the project and (unlike copy/pasting the content) would preserve all of the history, as your local repo knows it.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Jan 1 at 12:44









                Dave SherohmanDave Sherohman

                4,28411529




                4,28411529






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Super User!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1389508%2fmerging-two-divergent-repositories-on-different-remotes%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Probability when a professor distributes a quiz and homework assignment to a class of n students.

                    Aardman Animations

                    Are they similar matrix