Mercurial cancels three hg push

I use mercurial VCS, I mistakenly pushed three commits and I want them to be rolled back, can this be achieved? I am pretty sure that no changes were passed to anyone from the repository I clicked on, so I'm sure this will not break any code ...

I tried hg rollback, but since I clicked, I cannot undo anything correctly. I also know about the hg retreat, but I'm not sure if I will use this for what I need ...

Thanks!

EDIT

This is a graphic magazine, I forgot to mention that some commits were part of the merge, but they also need to be canceled ...

tip | a | \ | b | / c | d 

I need to return the prompt in c or d if there is no other way to prevent this from merging ...

+6
source share
2 answers

If it is already pressed, there are only two things you can do now:

1) If you can delete the central repository and replace it with another:
You can clone the central repository, but tell Mercurial to clone only until the c changeset .
Then you can take this repository (which does not have the wrong changes) and replace the "old" central repository (the one that has the wrong changes) with it.

Disadvantage: if someone has already pulled unwanted commits and then clicked again, they are again in the repository.
Therefore, you need to make sure that either no one was mistaken, or everyone who deleted his clone.

2) If option 1 is not possible, you can use hg backout to undo the effects of the wrong changes, rather than the changes themselves.
Quote from the link:

Relapse works by applying a set of changes that will be reversed in the opposite of the set of changes. This new set of changes is tied to the repository and ultimately merged.

Thus, three incorrect change sets will remain in the repository, plus three more will be added, each of which will return the effects of one of the three incorrect change sets.
If you do it this way, it doesn't matter if someone else pulled the wrong changes ... as soon as he pulls out three “backup” sets of changes, everything will be okay again.

+6
source

If you are sure that the click is the last thing that happened with this remote repository, that is, neither you nor anyone else clicked on it, you can log in to this system and run hg rollback .

If it is a repository on a computer on which you can ssh, you can run this command on your local system:

 ssh you@there hg -R /path/to/the/repo rollback 

As always, please be really careful with the rollback . It cancels the last action in the repository without changing the working directory at all, and it is not always clear what the last action is. For example, this is datalosss:

 ...hack... hg commit -m 'important work' hg update somewhere else hg rollback 

Hop!

+2
source

Source: https://habr.com/ru/post/908172/


All Articles