How to rebase an entire commit graph?











up vote
0
down vote

favorite












enter image description here



We have a project repository left.



Then we created a clone repository right from the topmost snapshot of the left (and worked there for some weeks).



How can we merge the two graphs?

(to let the team merge between the two)





NOTE: The stiching point contains the very same changeset, there are no conflicts involved.










share|improve this question




























    up vote
    0
    down vote

    favorite












    enter image description here



    We have a project repository left.



    Then we created a clone repository right from the topmost snapshot of the left (and worked there for some weeks).



    How can we merge the two graphs?

    (to let the team merge between the two)





    NOTE: The stiching point contains the very same changeset, there are no conflicts involved.










    share|improve this question


























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      enter image description here



      We have a project repository left.



      Then we created a clone repository right from the topmost snapshot of the left (and worked there for some weeks).



      How can we merge the two graphs?

      (to let the team merge between the two)





      NOTE: The stiching point contains the very same changeset, there are no conflicts involved.










      share|improve this question















      enter image description here



      We have a project repository left.



      Then we created a clone repository right from the topmost snapshot of the left (and worked there for some weeks).



      How can we merge the two graphs?

      (to let the team merge between the two)





      NOTE: The stiching point contains the very same changeset, there are no conflicts involved.







      git tree repository branch rebase






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 7 at 8:02

























      asked Nov 7 at 7:43









      Geri

      8,6911176132




      8,6911176132
























          1 Answer
          1






          active

          oldest

          votes

















          up vote
          1
          down vote



          accepted











          NOTE: The stiching point contains the very same changeset, there are no conflicts involved.




          So, I think you should use git replace.



          Most likely the command:



          git replace --graft <commit> [<parent>…​] 


          If I understand well, you want to link the first blue commit with the last orange which are commits which contains exactly the same content.



          The command is a little more complex because the last orange commit is a merge commit so you should use the sha1 of the 2 parents in the command line (the second to last orange and the last green).



          So the command should be:



          git replace --graft <Sha1_of_first_blue_commit> <Sha1_of_second_to_last_orange_commit> <Sha1_of_last_green_commit>


          Once done, verify the history.



          If that don't suits you, delete the replaced commit.



          If that suits you, then you should use git filter-branch to make it permanent (with git filter-branch -- --all) by rewriting all the history after the commit replaced.



          From doc:




          NOTE: This command honors .git/info/grafts file and refs in the refs/replace/ namespace. If you have any grafts or replacement refs defined, running this command will make them permanent.




          It will modify the history of blue and subsequent commits and so, to push it you will be obliged to do a git push --force-with-lease for all the refs that has been updated.



          PS: There is also the possibility to push the replaced object (a solution here ) but that's not the recommended solution.






          share|improve this answer























          • It is awesome, thanks for the extra with the merge commit thing! I'll try it later today (then come back to accept).
            – Geri
            Nov 7 at 9:36






          • 1




            I have updated my answer
            – Philippe
            Nov 7 at 11:09






          • 1




            I think that since git v2, only one branch is pushed at a time so you will be obliged to do it for each one...
            – Philippe
            Nov 7 at 12:10






          • 1




            Due to how git works, each commit being a snapshot, but something strange would have happened. The changes/diff introduced by the commit replaced would have been different containing also all the changes that make tail and tip different (sorry, difficult to explain)
            – Philippe
            Nov 9 at 21:40






          • 1




            The way git store commits allow you to stitch every commits together but the diff calculated and shown to the developer will have more or less sense. So select the commits carefully and the parent(s) commit that you should choose must be as similar as possible. You could even select an identical commit, so that the stitch will introduce no changes (diff empty).
            – Philippe
            Nov 10 at 9:19











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          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',
          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%2fstackoverflow.com%2fquestions%2f53185269%2fhow-to-rebase-an-entire-commit-graph%23new-answer', 'question_page');
          }
          );

          Post as a guest
































          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          1
          down vote



          accepted











          NOTE: The stiching point contains the very same changeset, there are no conflicts involved.




          So, I think you should use git replace.



          Most likely the command:



          git replace --graft <commit> [<parent>…​] 


          If I understand well, you want to link the first blue commit with the last orange which are commits which contains exactly the same content.



          The command is a little more complex because the last orange commit is a merge commit so you should use the sha1 of the 2 parents in the command line (the second to last orange and the last green).



          So the command should be:



          git replace --graft <Sha1_of_first_blue_commit> <Sha1_of_second_to_last_orange_commit> <Sha1_of_last_green_commit>


          Once done, verify the history.



          If that don't suits you, delete the replaced commit.



          If that suits you, then you should use git filter-branch to make it permanent (with git filter-branch -- --all) by rewriting all the history after the commit replaced.



          From doc:




          NOTE: This command honors .git/info/grafts file and refs in the refs/replace/ namespace. If you have any grafts or replacement refs defined, running this command will make them permanent.




          It will modify the history of blue and subsequent commits and so, to push it you will be obliged to do a git push --force-with-lease for all the refs that has been updated.



          PS: There is also the possibility to push the replaced object (a solution here ) but that's not the recommended solution.






          share|improve this answer























          • It is awesome, thanks for the extra with the merge commit thing! I'll try it later today (then come back to accept).
            – Geri
            Nov 7 at 9:36






          • 1




            I have updated my answer
            – Philippe
            Nov 7 at 11:09






          • 1




            I think that since git v2, only one branch is pushed at a time so you will be obliged to do it for each one...
            – Philippe
            Nov 7 at 12:10






          • 1




            Due to how git works, each commit being a snapshot, but something strange would have happened. The changes/diff introduced by the commit replaced would have been different containing also all the changes that make tail and tip different (sorry, difficult to explain)
            – Philippe
            Nov 9 at 21:40






          • 1




            The way git store commits allow you to stitch every commits together but the diff calculated and shown to the developer will have more or less sense. So select the commits carefully and the parent(s) commit that you should choose must be as similar as possible. You could even select an identical commit, so that the stitch will introduce no changes (diff empty).
            – Philippe
            Nov 10 at 9:19















          up vote
          1
          down vote



          accepted











          NOTE: The stiching point contains the very same changeset, there are no conflicts involved.




          So, I think you should use git replace.



          Most likely the command:



          git replace --graft <commit> [<parent>…​] 


          If I understand well, you want to link the first blue commit with the last orange which are commits which contains exactly the same content.



          The command is a little more complex because the last orange commit is a merge commit so you should use the sha1 of the 2 parents in the command line (the second to last orange and the last green).



          So the command should be:



          git replace --graft <Sha1_of_first_blue_commit> <Sha1_of_second_to_last_orange_commit> <Sha1_of_last_green_commit>


          Once done, verify the history.



          If that don't suits you, delete the replaced commit.



          If that suits you, then you should use git filter-branch to make it permanent (with git filter-branch -- --all) by rewriting all the history after the commit replaced.



          From doc:




          NOTE: This command honors .git/info/grafts file and refs in the refs/replace/ namespace. If you have any grafts or replacement refs defined, running this command will make them permanent.




          It will modify the history of blue and subsequent commits and so, to push it you will be obliged to do a git push --force-with-lease for all the refs that has been updated.



          PS: There is also the possibility to push the replaced object (a solution here ) but that's not the recommended solution.






          share|improve this answer























          • It is awesome, thanks for the extra with the merge commit thing! I'll try it later today (then come back to accept).
            – Geri
            Nov 7 at 9:36






          • 1




            I have updated my answer
            – Philippe
            Nov 7 at 11:09






          • 1




            I think that since git v2, only one branch is pushed at a time so you will be obliged to do it for each one...
            – Philippe
            Nov 7 at 12:10






          • 1




            Due to how git works, each commit being a snapshot, but something strange would have happened. The changes/diff introduced by the commit replaced would have been different containing also all the changes that make tail and tip different (sorry, difficult to explain)
            – Philippe
            Nov 9 at 21:40






          • 1




            The way git store commits allow you to stitch every commits together but the diff calculated and shown to the developer will have more or less sense. So select the commits carefully and the parent(s) commit that you should choose must be as similar as possible. You could even select an identical commit, so that the stitch will introduce no changes (diff empty).
            – Philippe
            Nov 10 at 9:19













          up vote
          1
          down vote



          accepted







          up vote
          1
          down vote



          accepted







          NOTE: The stiching point contains the very same changeset, there are no conflicts involved.




          So, I think you should use git replace.



          Most likely the command:



          git replace --graft <commit> [<parent>…​] 


          If I understand well, you want to link the first blue commit with the last orange which are commits which contains exactly the same content.



          The command is a little more complex because the last orange commit is a merge commit so you should use the sha1 of the 2 parents in the command line (the second to last orange and the last green).



          So the command should be:



          git replace --graft <Sha1_of_first_blue_commit> <Sha1_of_second_to_last_orange_commit> <Sha1_of_last_green_commit>


          Once done, verify the history.



          If that don't suits you, delete the replaced commit.



          If that suits you, then you should use git filter-branch to make it permanent (with git filter-branch -- --all) by rewriting all the history after the commit replaced.



          From doc:




          NOTE: This command honors .git/info/grafts file and refs in the refs/replace/ namespace. If you have any grafts or replacement refs defined, running this command will make them permanent.




          It will modify the history of blue and subsequent commits and so, to push it you will be obliged to do a git push --force-with-lease for all the refs that has been updated.



          PS: There is also the possibility to push the replaced object (a solution here ) but that's not the recommended solution.






          share|improve this answer















          NOTE: The stiching point contains the very same changeset, there are no conflicts involved.




          So, I think you should use git replace.



          Most likely the command:



          git replace --graft <commit> [<parent>…​] 


          If I understand well, you want to link the first blue commit with the last orange which are commits which contains exactly the same content.



          The command is a little more complex because the last orange commit is a merge commit so you should use the sha1 of the 2 parents in the command line (the second to last orange and the last green).



          So the command should be:



          git replace --graft <Sha1_of_first_blue_commit> <Sha1_of_second_to_last_orange_commit> <Sha1_of_last_green_commit>


          Once done, verify the history.



          If that don't suits you, delete the replaced commit.



          If that suits you, then you should use git filter-branch to make it permanent (with git filter-branch -- --all) by rewriting all the history after the commit replaced.



          From doc:




          NOTE: This command honors .git/info/grafts file and refs in the refs/replace/ namespace. If you have any grafts or replacement refs defined, running this command will make them permanent.




          It will modify the history of blue and subsequent commits and so, to push it you will be obliged to do a git push --force-with-lease for all the refs that has been updated.



          PS: There is also the possibility to push the replaced object (a solution here ) but that's not the recommended solution.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 7 at 11:09

























          answered Nov 7 at 9:17









          Philippe

          11.4k42543




          11.4k42543












          • It is awesome, thanks for the extra with the merge commit thing! I'll try it later today (then come back to accept).
            – Geri
            Nov 7 at 9:36






          • 1




            I have updated my answer
            – Philippe
            Nov 7 at 11:09






          • 1




            I think that since git v2, only one branch is pushed at a time so you will be obliged to do it for each one...
            – Philippe
            Nov 7 at 12:10






          • 1




            Due to how git works, each commit being a snapshot, but something strange would have happened. The changes/diff introduced by the commit replaced would have been different containing also all the changes that make tail and tip different (sorry, difficult to explain)
            – Philippe
            Nov 9 at 21:40






          • 1




            The way git store commits allow you to stitch every commits together but the diff calculated and shown to the developer will have more or less sense. So select the commits carefully and the parent(s) commit that you should choose must be as similar as possible. You could even select an identical commit, so that the stitch will introduce no changes (diff empty).
            – Philippe
            Nov 10 at 9:19


















          • It is awesome, thanks for the extra with the merge commit thing! I'll try it later today (then come back to accept).
            – Geri
            Nov 7 at 9:36






          • 1




            I have updated my answer
            – Philippe
            Nov 7 at 11:09






          • 1




            I think that since git v2, only one branch is pushed at a time so you will be obliged to do it for each one...
            – Philippe
            Nov 7 at 12:10






          • 1




            Due to how git works, each commit being a snapshot, but something strange would have happened. The changes/diff introduced by the commit replaced would have been different containing also all the changes that make tail and tip different (sorry, difficult to explain)
            – Philippe
            Nov 9 at 21:40






          • 1




            The way git store commits allow you to stitch every commits together but the diff calculated and shown to the developer will have more or less sense. So select the commits carefully and the parent(s) commit that you should choose must be as similar as possible. You could even select an identical commit, so that the stitch will introduce no changes (diff empty).
            – Philippe
            Nov 10 at 9:19
















          It is awesome, thanks for the extra with the merge commit thing! I'll try it later today (then come back to accept).
          – Geri
          Nov 7 at 9:36




          It is awesome, thanks for the extra with the merge commit thing! I'll try it later today (then come back to accept).
          – Geri
          Nov 7 at 9:36




          1




          1




          I have updated my answer
          – Philippe
          Nov 7 at 11:09




          I have updated my answer
          – Philippe
          Nov 7 at 11:09




          1




          1




          I think that since git v2, only one branch is pushed at a time so you will be obliged to do it for each one...
          – Philippe
          Nov 7 at 12:10




          I think that since git v2, only one branch is pushed at a time so you will be obliged to do it for each one...
          – Philippe
          Nov 7 at 12:10




          1




          1




          Due to how git works, each commit being a snapshot, but something strange would have happened. The changes/diff introduced by the commit replaced would have been different containing also all the changes that make tail and tip different (sorry, difficult to explain)
          – Philippe
          Nov 9 at 21:40




          Due to how git works, each commit being a snapshot, but something strange would have happened. The changes/diff introduced by the commit replaced would have been different containing also all the changes that make tail and tip different (sorry, difficult to explain)
          – Philippe
          Nov 9 at 21:40




          1




          1




          The way git store commits allow you to stitch every commits together but the diff calculated and shown to the developer will have more or less sense. So select the commits carefully and the parent(s) commit that you should choose must be as similar as possible. You could even select an identical commit, so that the stitch will introduce no changes (diff empty).
          – Philippe
          Nov 10 at 9:19




          The way git store commits allow you to stitch every commits together but the diff calculated and shown to the developer will have more or less sense. So select the commits carefully and the parent(s) commit that you should choose must be as similar as possible. You could even select an identical commit, so that the stitch will introduce no changes (diff empty).
          – Philippe
          Nov 10 at 9:19


















           

          draft saved


          draft discarded



















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53185269%2fhow-to-rebase-an-entire-commit-graph%23new-answer', 'question_page');
          }
          );

          Post as a guest




















































































          這個網誌中的熱門文章

          Tangent Lines Diagram Along Smooth Curve

          Yusuf al-Mu'taman ibn Hud

          Zucchini