How do I skip a GIT commit from a merge?












0















I have a question about undoing a commit in GIT. There was a merge commit (a commit from a merge) that broke the branch and I'm trying to fix the problem.



The problem is:



Commit 1 - by a developer. No bugs



Commit 2 - by a developer. No bugs. Everything copacetic here.



Merge commit 3 - by a developer from another remote GIT repo. This is not a commit from the developer into the Git repo. It's a commit because of a merge with another branch. You can see the difference in the git log output - there's a "Merge: commit number" entry after the commit hexsum value. This broke things and now compilation fails.



Commit 4 - by a developer. Right after Merge commit #3. Still broken because of the Merge commit #3.



We can wait for the developer who did the Merge commit 3 to fix it. Unfortunately, he's on vacation for 2 weeks and he did a "commit and run". And we don't want to wait for him to return.



What I would like to do is to fix the branch so that I can get commits #1, #2, ignore merge commit #3, and get commit #4.



I tried the "git rebase -i HEAD~4" command but unfortunately, this interactive command does NOT let you unpick Merge commits. Merge commits aren't even listed for this command.



Is there another way to ignore a merge commit?










share|improve this question


















  • 2





    did you try to cherry-pick the commit?

    – ɯɐɹʞ
    Jul 25 '18 at 23:47











  • It sounds like you need to undo a previous commit (i.e. commit #3) - did you try to git revert yet? (atlassian.com/git/tutorials/undoing-changes)

    – ochi
    Jul 25 '18 at 23:53













  • How do you cherry pick a commit? Do you mean I manually diff the files from commit #2 and commit #4 and then apply the changes?

    – SQA777
    Jul 26 '18 at 1:10











  • kram (upside down) - we did a git cherry pick.

    – SQA777
    Jul 30 '18 at 21:43
















0















I have a question about undoing a commit in GIT. There was a merge commit (a commit from a merge) that broke the branch and I'm trying to fix the problem.



The problem is:



Commit 1 - by a developer. No bugs



Commit 2 - by a developer. No bugs. Everything copacetic here.



Merge commit 3 - by a developer from another remote GIT repo. This is not a commit from the developer into the Git repo. It's a commit because of a merge with another branch. You can see the difference in the git log output - there's a "Merge: commit number" entry after the commit hexsum value. This broke things and now compilation fails.



Commit 4 - by a developer. Right after Merge commit #3. Still broken because of the Merge commit #3.



We can wait for the developer who did the Merge commit 3 to fix it. Unfortunately, he's on vacation for 2 weeks and he did a "commit and run". And we don't want to wait for him to return.



What I would like to do is to fix the branch so that I can get commits #1, #2, ignore merge commit #3, and get commit #4.



I tried the "git rebase -i HEAD~4" command but unfortunately, this interactive command does NOT let you unpick Merge commits. Merge commits aren't even listed for this command.



Is there another way to ignore a merge commit?










share|improve this question


















  • 2





    did you try to cherry-pick the commit?

    – ɯɐɹʞ
    Jul 25 '18 at 23:47











  • It sounds like you need to undo a previous commit (i.e. commit #3) - did you try to git revert yet? (atlassian.com/git/tutorials/undoing-changes)

    – ochi
    Jul 25 '18 at 23:53













  • How do you cherry pick a commit? Do you mean I manually diff the files from commit #2 and commit #4 and then apply the changes?

    – SQA777
    Jul 26 '18 at 1:10











  • kram (upside down) - we did a git cherry pick.

    – SQA777
    Jul 30 '18 at 21:43














0












0








0








I have a question about undoing a commit in GIT. There was a merge commit (a commit from a merge) that broke the branch and I'm trying to fix the problem.



The problem is:



Commit 1 - by a developer. No bugs



Commit 2 - by a developer. No bugs. Everything copacetic here.



Merge commit 3 - by a developer from another remote GIT repo. This is not a commit from the developer into the Git repo. It's a commit because of a merge with another branch. You can see the difference in the git log output - there's a "Merge: commit number" entry after the commit hexsum value. This broke things and now compilation fails.



Commit 4 - by a developer. Right after Merge commit #3. Still broken because of the Merge commit #3.



We can wait for the developer who did the Merge commit 3 to fix it. Unfortunately, he's on vacation for 2 weeks and he did a "commit and run". And we don't want to wait for him to return.



What I would like to do is to fix the branch so that I can get commits #1, #2, ignore merge commit #3, and get commit #4.



I tried the "git rebase -i HEAD~4" command but unfortunately, this interactive command does NOT let you unpick Merge commits. Merge commits aren't even listed for this command.



Is there another way to ignore a merge commit?










share|improve this question














I have a question about undoing a commit in GIT. There was a merge commit (a commit from a merge) that broke the branch and I'm trying to fix the problem.



The problem is:



Commit 1 - by a developer. No bugs



Commit 2 - by a developer. No bugs. Everything copacetic here.



Merge commit 3 - by a developer from another remote GIT repo. This is not a commit from the developer into the Git repo. It's a commit because of a merge with another branch. You can see the difference in the git log output - there's a "Merge: commit number" entry after the commit hexsum value. This broke things and now compilation fails.



Commit 4 - by a developer. Right after Merge commit #3. Still broken because of the Merge commit #3.



We can wait for the developer who did the Merge commit 3 to fix it. Unfortunately, he's on vacation for 2 weeks and he did a "commit and run". And we don't want to wait for him to return.



What I would like to do is to fix the branch so that I can get commits #1, #2, ignore merge commit #3, and get commit #4.



I tried the "git rebase -i HEAD~4" command but unfortunately, this interactive command does NOT let you unpick Merge commits. Merge commits aren't even listed for this command.



Is there another way to ignore a merge commit?







git






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Jul 25 '18 at 23:34









SQA777SQA777

58110




58110








  • 2





    did you try to cherry-pick the commit?

    – ɯɐɹʞ
    Jul 25 '18 at 23:47











  • It sounds like you need to undo a previous commit (i.e. commit #3) - did you try to git revert yet? (atlassian.com/git/tutorials/undoing-changes)

    – ochi
    Jul 25 '18 at 23:53













  • How do you cherry pick a commit? Do you mean I manually diff the files from commit #2 and commit #4 and then apply the changes?

    – SQA777
    Jul 26 '18 at 1:10











  • kram (upside down) - we did a git cherry pick.

    – SQA777
    Jul 30 '18 at 21:43














  • 2





    did you try to cherry-pick the commit?

    – ɯɐɹʞ
    Jul 25 '18 at 23:47











  • It sounds like you need to undo a previous commit (i.e. commit #3) - did you try to git revert yet? (atlassian.com/git/tutorials/undoing-changes)

    – ochi
    Jul 25 '18 at 23:53













  • How do you cherry pick a commit? Do you mean I manually diff the files from commit #2 and commit #4 and then apply the changes?

    – SQA777
    Jul 26 '18 at 1:10











  • kram (upside down) - we did a git cherry pick.

    – SQA777
    Jul 30 '18 at 21:43








2




2





did you try to cherry-pick the commit?

– ɯɐɹʞ
Jul 25 '18 at 23:47





did you try to cherry-pick the commit?

– ɯɐɹʞ
Jul 25 '18 at 23:47













It sounds like you need to undo a previous commit (i.e. commit #3) - did you try to git revert yet? (atlassian.com/git/tutorials/undoing-changes)

– ochi
Jul 25 '18 at 23:53







It sounds like you need to undo a previous commit (i.e. commit #3) - did you try to git revert yet? (atlassian.com/git/tutorials/undoing-changes)

– ochi
Jul 25 '18 at 23:53















How do you cherry pick a commit? Do you mean I manually diff the files from commit #2 and commit #4 and then apply the changes?

– SQA777
Jul 26 '18 at 1:10





How do you cherry pick a commit? Do you mean I manually diff the files from commit #2 and commit #4 and then apply the changes?

– SQA777
Jul 26 '18 at 1:10













kram (upside down) - we did a git cherry pick.

– SQA777
Jul 30 '18 at 21:43





kram (upside down) - we did a git cherry pick.

– SQA777
Jul 30 '18 at 21:43












3 Answers
3






active

oldest

votes


















2














Option 1, preferred



Just fix it. You're a team. Have one another's back.



Option 2, reverse the commit



git revert SHA_of_the_bad_commit_here
git commit -m "Reverting commit XXX by bad_bad_developer - it broke the build"


This doesn't change history and is quite a good option



** Option 3, another branch **



This could work if this is not a special branch (e.g. develop, master, or whatever important branches you have ) or if you are OK to work on another branch until _bad_bad_dev_ comes back and fixes the original branch.



Create a new branch from the commit2 -> switch to that new branch and apply commit 4 -> keep working



Option 4, git reset



This is the option by @ochi - it changes history and cause headaches if the branch is shared, which it seems to be the case.






share|improve this answer


























  • We went with Option #3. Option #1 would have been the best way but the developer didn't test his code before merge, didn't even attempt to test if it would compile, and just merged it and took off, which is against standard operating procedures. I won't clean up other people's mess if they break rules to create the mess.

    – SQA777
    Jul 30 '18 at 21:41













  • Great, I'm glad the issue is resolved now.

    – tymtam
    Jul 30 '18 at 23:56



















1














You could try to reset to a certain commit (i.e. #2) and apply the changes in commit #4



git reset --hard <commit-#2-id>
git commit -m "commit #4"
git push





share|improve this answer



















  • 1





    In a shared environment you most likely would have to --force which can lead to hard to solve issues.

    – tymtam
    Jul 26 '18 at 1:10











  • @tymtam fair comment :)

    – ochi
    Jul 26 '18 at 1:14



















0














You should just revert back to Commit 2 , find the branch that was created for COmmit 4, then merge that branch into whatever branch this is in.






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%2f51529063%2fhow-do-i-skip-a-git-commit-from-a-merge%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    3 Answers
    3






    active

    oldest

    votes








    3 Answers
    3






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    2














    Option 1, preferred



    Just fix it. You're a team. Have one another's back.



    Option 2, reverse the commit



    git revert SHA_of_the_bad_commit_here
    git commit -m "Reverting commit XXX by bad_bad_developer - it broke the build"


    This doesn't change history and is quite a good option



    ** Option 3, another branch **



    This could work if this is not a special branch (e.g. develop, master, or whatever important branches you have ) or if you are OK to work on another branch until _bad_bad_dev_ comes back and fixes the original branch.



    Create a new branch from the commit2 -> switch to that new branch and apply commit 4 -> keep working



    Option 4, git reset



    This is the option by @ochi - it changes history and cause headaches if the branch is shared, which it seems to be the case.






    share|improve this answer


























    • We went with Option #3. Option #1 would have been the best way but the developer didn't test his code before merge, didn't even attempt to test if it would compile, and just merged it and took off, which is against standard operating procedures. I won't clean up other people's mess if they break rules to create the mess.

      – SQA777
      Jul 30 '18 at 21:41













    • Great, I'm glad the issue is resolved now.

      – tymtam
      Jul 30 '18 at 23:56
















    2














    Option 1, preferred



    Just fix it. You're a team. Have one another's back.



    Option 2, reverse the commit



    git revert SHA_of_the_bad_commit_here
    git commit -m "Reverting commit XXX by bad_bad_developer - it broke the build"


    This doesn't change history and is quite a good option



    ** Option 3, another branch **



    This could work if this is not a special branch (e.g. develop, master, or whatever important branches you have ) or if you are OK to work on another branch until _bad_bad_dev_ comes back and fixes the original branch.



    Create a new branch from the commit2 -> switch to that new branch and apply commit 4 -> keep working



    Option 4, git reset



    This is the option by @ochi - it changes history and cause headaches if the branch is shared, which it seems to be the case.






    share|improve this answer


























    • We went with Option #3. Option #1 would have been the best way but the developer didn't test his code before merge, didn't even attempt to test if it would compile, and just merged it and took off, which is against standard operating procedures. I won't clean up other people's mess if they break rules to create the mess.

      – SQA777
      Jul 30 '18 at 21:41













    • Great, I'm glad the issue is resolved now.

      – tymtam
      Jul 30 '18 at 23:56














    2












    2








    2







    Option 1, preferred



    Just fix it. You're a team. Have one another's back.



    Option 2, reverse the commit



    git revert SHA_of_the_bad_commit_here
    git commit -m "Reverting commit XXX by bad_bad_developer - it broke the build"


    This doesn't change history and is quite a good option



    ** Option 3, another branch **



    This could work if this is not a special branch (e.g. develop, master, or whatever important branches you have ) or if you are OK to work on another branch until _bad_bad_dev_ comes back and fixes the original branch.



    Create a new branch from the commit2 -> switch to that new branch and apply commit 4 -> keep working



    Option 4, git reset



    This is the option by @ochi - it changes history and cause headaches if the branch is shared, which it seems to be the case.






    share|improve this answer















    Option 1, preferred



    Just fix it. You're a team. Have one another's back.



    Option 2, reverse the commit



    git revert SHA_of_the_bad_commit_here
    git commit -m "Reverting commit XXX by bad_bad_developer - it broke the build"


    This doesn't change history and is quite a good option



    ** Option 3, another branch **



    This could work if this is not a special branch (e.g. develop, master, or whatever important branches you have ) or if you are OK to work on another branch until _bad_bad_dev_ comes back and fixes the original branch.



    Create a new branch from the commit2 -> switch to that new branch and apply commit 4 -> keep working



    Option 4, git reset



    This is the option by @ochi - it changes history and cause headaches if the branch is shared, which it seems to be the case.







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Jan 3 at 11:28









    marc_s

    583k13011241270




    583k13011241270










    answered Jul 26 '18 at 1:02









    tymtamtymtam

    6,77233657




    6,77233657













    • We went with Option #3. Option #1 would have been the best way but the developer didn't test his code before merge, didn't even attempt to test if it would compile, and just merged it and took off, which is against standard operating procedures. I won't clean up other people's mess if they break rules to create the mess.

      – SQA777
      Jul 30 '18 at 21:41













    • Great, I'm glad the issue is resolved now.

      – tymtam
      Jul 30 '18 at 23:56



















    • We went with Option #3. Option #1 would have been the best way but the developer didn't test his code before merge, didn't even attempt to test if it would compile, and just merged it and took off, which is against standard operating procedures. I won't clean up other people's mess if they break rules to create the mess.

      – SQA777
      Jul 30 '18 at 21:41













    • Great, I'm glad the issue is resolved now.

      – tymtam
      Jul 30 '18 at 23:56

















    We went with Option #3. Option #1 would have been the best way but the developer didn't test his code before merge, didn't even attempt to test if it would compile, and just merged it and took off, which is against standard operating procedures. I won't clean up other people's mess if they break rules to create the mess.

    – SQA777
    Jul 30 '18 at 21:41







    We went with Option #3. Option #1 would have been the best way but the developer didn't test his code before merge, didn't even attempt to test if it would compile, and just merged it and took off, which is against standard operating procedures. I won't clean up other people's mess if they break rules to create the mess.

    – SQA777
    Jul 30 '18 at 21:41















    Great, I'm glad the issue is resolved now.

    – tymtam
    Jul 30 '18 at 23:56





    Great, I'm glad the issue is resolved now.

    – tymtam
    Jul 30 '18 at 23:56













    1














    You could try to reset to a certain commit (i.e. #2) and apply the changes in commit #4



    git reset --hard <commit-#2-id>
    git commit -m "commit #4"
    git push





    share|improve this answer



















    • 1





      In a shared environment you most likely would have to --force which can lead to hard to solve issues.

      – tymtam
      Jul 26 '18 at 1:10











    • @tymtam fair comment :)

      – ochi
      Jul 26 '18 at 1:14
















    1














    You could try to reset to a certain commit (i.e. #2) and apply the changes in commit #4



    git reset --hard <commit-#2-id>
    git commit -m "commit #4"
    git push





    share|improve this answer



















    • 1





      In a shared environment you most likely would have to --force which can lead to hard to solve issues.

      – tymtam
      Jul 26 '18 at 1:10











    • @tymtam fair comment :)

      – ochi
      Jul 26 '18 at 1:14














    1












    1








    1







    You could try to reset to a certain commit (i.e. #2) and apply the changes in commit #4



    git reset --hard <commit-#2-id>
    git commit -m "commit #4"
    git push





    share|improve this answer













    You could try to reset to a certain commit (i.e. #2) and apply the changes in commit #4



    git reset --hard <commit-#2-id>
    git commit -m "commit #4"
    git push






    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Jul 26 '18 at 0:10









    ochiochi

    9,07143551




    9,07143551








    • 1





      In a shared environment you most likely would have to --force which can lead to hard to solve issues.

      – tymtam
      Jul 26 '18 at 1:10











    • @tymtam fair comment :)

      – ochi
      Jul 26 '18 at 1:14














    • 1





      In a shared environment you most likely would have to --force which can lead to hard to solve issues.

      – tymtam
      Jul 26 '18 at 1:10











    • @tymtam fair comment :)

      – ochi
      Jul 26 '18 at 1:14








    1




    1





    In a shared environment you most likely would have to --force which can lead to hard to solve issues.

    – tymtam
    Jul 26 '18 at 1:10





    In a shared environment you most likely would have to --force which can lead to hard to solve issues.

    – tymtam
    Jul 26 '18 at 1:10













    @tymtam fair comment :)

    – ochi
    Jul 26 '18 at 1:14





    @tymtam fair comment :)

    – ochi
    Jul 26 '18 at 1:14











    0














    You should just revert back to Commit 2 , find the branch that was created for COmmit 4, then merge that branch into whatever branch this is in.






    share|improve this answer




























      0














      You should just revert back to Commit 2 , find the branch that was created for COmmit 4, then merge that branch into whatever branch this is in.






      share|improve this answer


























        0












        0








        0







        You should just revert back to Commit 2 , find the branch that was created for COmmit 4, then merge that branch into whatever branch this is in.






        share|improve this answer













        You should just revert back to Commit 2 , find the branch that was created for COmmit 4, then merge that branch into whatever branch this is in.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Jul 26 '18 at 0:14









        joeyjoey

        2,2232329




        2,2232329






























            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.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f51529063%2fhow-do-i-skip-a-git-commit-from-a-merge%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

            Monofisismo

            Angular Downloading a file using contenturl with Basic Authentication

            Olmecas