Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4587310
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T21:45:43+00:00 2026-05-21T21:45:43+00:00

Let’s suppose it was performed merge with Discard all changes from merge … option,

  • 0

Let’s suppose it was performed merge with “Discard all changes from merge …” option, bu accident.

And this wrong commit has been committed into the “central” repository.

How to deal with this case if I need to merge in correct way the branch changes?

Commands to reproduce the case:

hg init mr
cd mr

echo "123" > file.txt
hg add
hg ci -m "initial"

hg branch br
echo "234" >> file.txt
hg ci -m "in branch"

hg up default
echo "567" >> file.txt
hg ci -m "in default"

After these commands open tortoisehg, and merge 2nd revision (default head) with br branch with “Discard …” option.

UPD:

It is a question about doing the opposite How to merge to get rid of head with Mercurial command line, like I can do with TortoiseHg? 😉

But still cannot find how to revert that step 🙁

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T21:45:44+00:00Added an answer on May 21, 2026 at 9:45 pm

    One way would be to redo the merge, and do yet another merge with discard.

    In your example, update back to the 2nd revision (the current working directory parent before you did the bad merge), then redo the merge with that other branch. Do it properly this time.

    This will give you another head.

    Then, merge with the old, incorrect merge, and choose discard on this. Now you have effectively bypassed this merge with a correct one.

    If you’re unsure about the steps, make a local clone and experiment, you can always just discard it and reclone and try again.

    Revision 3 is the old, incorrect merge, where I chose discard. After doing merge 4 and 5, the traces of that merge is gone and everything is back in working order. Yes, the history looks a little funky, but trust me, the cleanup procedures to get rid of that bad merge completely is far worse than the little hickup on your history timeline.

    Basically you have this scenario after the botched merge:

                +-- botched merge
                v
        0---2---3
         \     /
          1---+
    

    So you update back to the working folder parent you had before the bad merge, and do another merge, this time properly. Now it looks like this:

                +-- botched merge
                v
        0---2---3
         \   \ /
          \   x
           1-+-4
               ^
               +-- good merge
    

    Your working folder is now at revision 4, so you do yet another merge, this time with revision 3 (the bad merge), and choose to discard those changes, and you get this:

                +-- botched merge
                v
        0---2---3-5  <-- final merge, discard 3
         \   \ / /
          \   x /
           1-+-4
               ^
               +-- good merge
    

    Here’s how TortoiseHg shows this:

    history after new merges

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
Let's suppose I have this piece of code. foreach(string value in myList) { string
Let me preface this question by saying I use TextMate on Mac OSX for
Let's say on a page I have alot of this repeated: <div class=entry> <h4>Magic:</h4>
Let's say I can call a method like this: core::get() . What is the
Let's say I have a text file composed like this ##### typeofthread1 ##### typeofthread2
Let's say I have this code: <p dataname=description> Hello this is a description. <a
Let's say I wanted to remove vowels from HTML: <a href=foo>Hello there!</a>Hi! becomes <a
Let me frame it this way.. Say I have an application server running on
Let's take a common example how a haskell function can be called from a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.