Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to uncommit in mercurial for my last commit(not yet pushed) [duplicate]

Tags:

mercurial

I have situation like this:

I have commited files a,b,c,d.Now i found that by mistake i commited files a and b; so before pushing these changes, i want to do uncommit files a and b so that i can push only c and d.Can someone tell me how to do that by using mercurial commands.

Here uncommit means that i dunt want to use "hg out -p" and after that looking change set and do things manually.

like image 396
skg Avatar asked Mar 08 '12 11:03

skg


People also ask

How can I delete last commit in Mercurial?

If you are still in the draft phase (not pushed elsewhere yet), use the built-in extension hg strip <rev> command. Otherwise, you should do a hg backout , which will reverse the changeset. In case you still need the commit you made, I suggest you export it to import it again in the correct branch, before stripping.

How do you revert push changes in mercurial?

You need to login to the server and use the hg strip command. If you cannot login to the server, you are out of luck; you can hg backout then push again, but this will leave the bad commits on the server along with the commit that undoes them. Show activity on this post. hg revert -r .

What is hg amend?

hg amend [OPTION]... [ FILE]... aliases: refresh. combine a changeset with updates and replace it with a new one. Commits a new changeset incorporating both the changes to the given files and all the changes from the current parent changeset into the repository.


1 Answers

Assuming you haven't performed any other transactions on your repository since you committed the files, I think you could do this as a 2 stage process:

hg rollback hg commit filec filed 

hg rollback should remove the commit that you have just made, but leave the files as changed. Then hg commit filec filed should commit the files named filec & filed. Obviously you should replace these file names with the names of your actual files.

It's probably worth mentioning that you should be careful with hg rollback - it alters the history, so it is possible to lose data with it if used incorrectly.

like image 186
obmarg Avatar answered Sep 29 '22 14:09

obmarg