At work I use my working E-Mail address when creating commit messages, but at home I use my private account for creating commits.
I forgot to change back to my working email address before committing and pushing and then I realized that I pushed a Merge
commit with my private email address and I would like to basically modify this commit message to my working email address.
In Git
it's extremely easy when I needed to rebase from certain child commit and then force push it and it works perfectly fine, but in Mercurial
it seems to be more restricted and I'm pretty sure there must be a way, as I saw many similar questions in Stackoverflow like amending commit, I also read some articles using some of the famous Mercurial extensions like: histedit
, evolve
and rebase
.
Some other things I tried also failed:
- Using the
hgext.convert
creates a new repository which I don't want and it also failed to finish in one of my changesets. - Using
histedit
throws an error that it can't modify public changes. - Using
hgext.mq
throws an error that it cannot import merge revision.
Why is it so complicated in mercurial?
One of the articles that I also checked is this one:
https://book.mercurial-scm.org/read/changing-history.html
Note that I already understand the meaning of it and how dangerous it can be when others working on this repository, so please try to save this from me :)
Another note that I normally use SourceTree
and sometimes command line, so if you're the kind of SourceTree person, I would also be happy to hear your solutions.
And please try to avoid marking this question as duplicate, as I've already used the search and have seen many different solutions that didn't really clarified this.
Is there a similar way as in Git
to basically rebase from specific commit and force push so I can change my email back to my working email address?
Thanks in advance for your time and effort to help! :)
EDIT 1:
My attempt to reproduce it on test public repository with pushed changes based on @DaveInCaz Solution, but failed:
Steps:
// Updating to the wrong commit message.
hg update -r B
// Throwing all changes that has been made on the wrong commit.
hg strip B
// Re-creating the Merge again with the correct mail address.
hg merge new-feature
// Assuming now it creates revision B2
hg commit -m 'Merge'
// Pulling the changes again
hg pull
// Making the correct commits afterwards to be the children from B2 instead B.
hg rebase -s C -d B2
// Removing the old B
hg strip B
And now of course if I try hg push
, I get the following abort: push creates new remote head
.