If we committed several times, for example, on our local repo, for revision 3000, 3001, 3002, 3003. If we push to a remote repo, it will push 3000 to 3003. Is there a way to push only 3000 and 3001?
If you want to revert just the latest commit use: hg strip --keep -r . Using strip will revert the state of your files to the specified commit but you will have them as pending changes, so you can apply them together with your file to a new commit.
Use the command hg update to switch to an existing branch. Use hg commit --close-branch to mark this branch head as closed.
Yes, you can select a revision to push. hg push -r 3001
(all ancestors of the chosen revision will be pushed; you don't need to specify 3000.)
If you need to push some changesets without all ancestors (solution described in @Woolble's answer), a good option is to use Mercurial Queues extension (MQ).
https://www.mercurial-scm.org/wiki/MqExtension
This will let you re-order and even combine changesets so you can push them in whatever order you like. It takes a bit of work to get started but you'll find it well worth the effort.
I've TortoiseHg makes working with MQ pretty straightforward.
For those who are using UI and like pictures:
In TortoiseHg click on Detect outgoing changes to
button.
Click right mouse button on revision you want to push.
Choose Push -> Push to Here
.
Result: You will push only revision selected rather than everything.
Hope this saves you some time.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With