Checking out branch and rebasing/merging temporarily to see impact?











up vote
1
down vote

favorite












Oftentimes, in our workflow we have a branch which tracks a remote pending pull request and I want to see preemptively what that PR will do to my PR before it's merged into master. For example, let's say there's a PR branch bar that hasn't been merged into master but I want to see how my PR branch foo which is being developed concurrently will be impacted by this change.



So I was thinking I could rebase foo onto bar (or merge) and then use reflog to reset foo back to its original spot, effectively undoing the rebase. However, I thought there may be a more efficient/elegant way to do this. Is there any similar functionality that would stop the branch pointer from being moved but allow us to see (in maybe a detached HEAD state) what impact one branch has on the other?










share|improve this question


















  • 1




    Simply create and check out a throwaway branch foo2 that points to the same commit as foo does (git checkout -b foo2 foo); do whatever you want with foo2, then remove it. This approach is simpler and safer than manipulating foo (and its reflog) directly.
    – jubobs
    Nov 10 at 8:15








  • 1




    @jubobs wow that's really smart actually! Thanks!
    – rb612
    Nov 10 at 8:16















up vote
1
down vote

favorite












Oftentimes, in our workflow we have a branch which tracks a remote pending pull request and I want to see preemptively what that PR will do to my PR before it's merged into master. For example, let's say there's a PR branch bar that hasn't been merged into master but I want to see how my PR branch foo which is being developed concurrently will be impacted by this change.



So I was thinking I could rebase foo onto bar (or merge) and then use reflog to reset foo back to its original spot, effectively undoing the rebase. However, I thought there may be a more efficient/elegant way to do this. Is there any similar functionality that would stop the branch pointer from being moved but allow us to see (in maybe a detached HEAD state) what impact one branch has on the other?










share|improve this question


















  • 1




    Simply create and check out a throwaway branch foo2 that points to the same commit as foo does (git checkout -b foo2 foo); do whatever you want with foo2, then remove it. This approach is simpler and safer than manipulating foo (and its reflog) directly.
    – jubobs
    Nov 10 at 8:15








  • 1




    @jubobs wow that's really smart actually! Thanks!
    – rb612
    Nov 10 at 8:16













up vote
1
down vote

favorite









up vote
1
down vote

favorite











Oftentimes, in our workflow we have a branch which tracks a remote pending pull request and I want to see preemptively what that PR will do to my PR before it's merged into master. For example, let's say there's a PR branch bar that hasn't been merged into master but I want to see how my PR branch foo which is being developed concurrently will be impacted by this change.



So I was thinking I could rebase foo onto bar (or merge) and then use reflog to reset foo back to its original spot, effectively undoing the rebase. However, I thought there may be a more efficient/elegant way to do this. Is there any similar functionality that would stop the branch pointer from being moved but allow us to see (in maybe a detached HEAD state) what impact one branch has on the other?










share|improve this question













Oftentimes, in our workflow we have a branch which tracks a remote pending pull request and I want to see preemptively what that PR will do to my PR before it's merged into master. For example, let's say there's a PR branch bar that hasn't been merged into master but I want to see how my PR branch foo which is being developed concurrently will be impacted by this change.



So I was thinking I could rebase foo onto bar (or merge) and then use reflog to reset foo back to its original spot, effectively undoing the rebase. However, I thought there may be a more efficient/elegant way to do this. Is there any similar functionality that would stop the branch pointer from being moved but allow us to see (in maybe a detached HEAD state) what impact one branch has on the other?







git github






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 10 at 8:14









rb612

1,37611030




1,37611030








  • 1




    Simply create and check out a throwaway branch foo2 that points to the same commit as foo does (git checkout -b foo2 foo); do whatever you want with foo2, then remove it. This approach is simpler and safer than manipulating foo (and its reflog) directly.
    – jubobs
    Nov 10 at 8:15








  • 1




    @jubobs wow that's really smart actually! Thanks!
    – rb612
    Nov 10 at 8:16














  • 1




    Simply create and check out a throwaway branch foo2 that points to the same commit as foo does (git checkout -b foo2 foo); do whatever you want with foo2, then remove it. This approach is simpler and safer than manipulating foo (and its reflog) directly.
    – jubobs
    Nov 10 at 8:15








  • 1




    @jubobs wow that's really smart actually! Thanks!
    – rb612
    Nov 10 at 8:16








1




1




Simply create and check out a throwaway branch foo2 that points to the same commit as foo does (git checkout -b foo2 foo); do whatever you want with foo2, then remove it. This approach is simpler and safer than manipulating foo (and its reflog) directly.
– jubobs
Nov 10 at 8:15






Simply create and check out a throwaway branch foo2 that points to the same commit as foo does (git checkout -b foo2 foo); do whatever you want with foo2, then remove it. This approach is simpler and safer than manipulating foo (and its reflog) directly.
– jubobs
Nov 10 at 8:15






1




1




@jubobs wow that's really smart actually! Thanks!
– rb612
Nov 10 at 8:16




@jubobs wow that's really smart actually! Thanks!
– rb612
Nov 10 at 8:16












1 Answer
1






active

oldest

votes

















up vote
1
down vote



accepted










Simply...





  1. Create and check out a throwaway branch, named foo2, say, that points to the same commit as foo does:



    git checkout -b foo2 foo


  2. Do whatever you want with branch foo2 (rebase it, etc.).



  3. When you're done, remove foo2:



    git branch -d foo2



This approach is simpler and safer than manipulating foo (and its reflog) directly.






share|improve this answer





















    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',
    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%2fstackoverflow.com%2fquestions%2f53237188%2fchecking-out-branch-and-rebasing-merging-temporarily-to-see-impact%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








    up vote
    1
    down vote



    accepted










    Simply...





    1. Create and check out a throwaway branch, named foo2, say, that points to the same commit as foo does:



      git checkout -b foo2 foo


    2. Do whatever you want with branch foo2 (rebase it, etc.).



    3. When you're done, remove foo2:



      git branch -d foo2



    This approach is simpler and safer than manipulating foo (and its reflog) directly.






    share|improve this answer

























      up vote
      1
      down vote



      accepted










      Simply...





      1. Create and check out a throwaway branch, named foo2, say, that points to the same commit as foo does:



        git checkout -b foo2 foo


      2. Do whatever you want with branch foo2 (rebase it, etc.).



      3. When you're done, remove foo2:



        git branch -d foo2



      This approach is simpler and safer than manipulating foo (and its reflog) directly.






      share|improve this answer























        up vote
        1
        down vote



        accepted







        up vote
        1
        down vote



        accepted






        Simply...





        1. Create and check out a throwaway branch, named foo2, say, that points to the same commit as foo does:



          git checkout -b foo2 foo


        2. Do whatever you want with branch foo2 (rebase it, etc.).



        3. When you're done, remove foo2:



          git branch -d foo2



        This approach is simpler and safer than manipulating foo (and its reflog) directly.






        share|improve this answer












        Simply...





        1. Create and check out a throwaway branch, named foo2, say, that points to the same commit as foo does:



          git checkout -b foo2 foo


        2. Do whatever you want with branch foo2 (rebase it, etc.).



        3. When you're done, remove foo2:



          git branch -d foo2



        This approach is simpler and safer than manipulating foo (and its reflog) directly.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 12 at 9:17









        jubobs

        32.6k17100124




        32.6k17100124






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • 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.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • 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%2fstackoverflow.com%2fquestions%2f53237188%2fchecking-out-branch-and-rebasing-merging-temporarily-to-see-impact%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







            這個網誌中的熱門文章

            Xamarin.form Move up view when keyboard appear

            Post-Redirect-Get with Spring WebFlux and Thymeleaf

            Anylogic : not able to use stopDelay()