Undo an hg push (backout?)

淺唱寂寞╮ 提交于 2019-11-29 22:09:48

hg rollback reverts the last transaction, so you'd be left with unfinished merge, which you have to use hg update -C to get out.

If you don't want *b (you have it in another clone), then enable the built-in MQ extension and run hg strip -r <*b>. It will get rid of *b and *merge. By default it saves a backup in case you change your mind again.


UPDATE (per @Rudi's comment: sorry I missed the "already pushed" part)

Since the merge is already pushed out, NEVER EVER do what I suggested earlier. Hate emails from fellow developers would have been the best outcome.

Do this instead:

hg up -r<*merge>
hg revert -r<*a> -a
hg ci -m "undo unintended merge"

Or you could be more kosher:

hg up -r<*merge>
hg backout -r<*merge> --parent<*a>
Michal Sznajder

I think it to late to make hg rollback since you have already pushed your changes.

You might try with MQ extensions but this also works locally. hg strip will only modify your local repo. You could of course try to modify your server repo directly on server but if somebody pulled it it is too late.

Another option is described in chapter 9 of hgbook in section Backing out a merge. It involves hg backout command but it might be an overkill for you...

I suggest to hg update -C to *a revision, merge with tip and ignore all changes from *merge? Your repository will look more or less like this than:

*second merge
 |  \ 
 |   \ 
 |    \     
 |     \ 
*merge | 
| \    |
|  \   |
|   *b |
*a  | /
|  / /
*c---

Commands for this are

  • $ hg --config ui.merge=internal:local merge #keep my files
  • $ hg --config ui.merge=internal:other merge #keep their files

More details could be found here.

Lie Ryan

hg rollback will revert the one last commit, deleting any history that would otherwise been made.

So, if you start with this:

*merge
| \
|  \
|   *b
*a  |
|  / 
*c

hg rollback will give:

*a  *b
|  / 
*c

note that you can only do hg rollback only once.

You should make a complete backup of the repository before doing rollback. To do this, simply hg clone the whole repository.

Szymon Toda

You all present little to complicated solution to this problem, that can occur to any of us.

What I did, I logged on remote desktop to my central repository, and there with mq extension changed revision status to "draft" and "stip"-ed them.

The only downside of it is, if someone has copy of repo with stripped revisions and will push, they will reappear. So if you can, ask others to a) do the same (draft, strip) b) delete their local repository and resync with modified one

All can be achieved easily with TortoiseHg.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!