Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Undo a remove action in Mercurial

Tags:

mercurial

Suppose that I have made some changes in the working directory and accidentally marked several files (that include some of the modified ones) for removal. How do I unmark the files for removal without losing the changes I have made?

like image 397
Kostas Avatar asked Feb 01 '10 09:02

Kostas


People also ask

How do you undo a pull in mercurial?

There is only one level of rollback, and there is no way to undo a rollback. It will also restore the dirstate at the time of the last transaction, losing any dirstate changes since that time. This command does not alter the working directory.

How do I revert changes in mercurial?

Revert changes already committed To backout a specific changeset use hg backout -r CHANGESET . This will prompt you directly with a request for the commit message to use in the backout. To revert a file to a specific changeset, use hg revert -r CHANGESET FILENAME . This will revert the file without committing it.

How do I revert my hg add?

hg revert -r . ^ path-to-file will revert the commit from the commit-set. then commit and submit (if using jelly fish) and you'll see the files removed from the changeset.

What is hg revert?

hg revert changes the file content only and leaves the working copy parent revision alone.


1 Answers

Just hg add the files.

I don't know why you're getting some many answers that modify the working directory. If you've accidentally marked some files for removal you can undo it with add.

ry4an@four:~/hgtest$ hg status --all M another_file C a_file ry4an@four:~/hgtest$ hg remove --after --force * ry4an@four:~/hgtest$ hg status --all R a_file R another_file ry4an@four:~/hgtest$ hg add * ry4an@four:~/hgtest$ hg status --all M another_file C a_file 

That said, don't use --force with hg remove or ever really. Also try to get in the habit of using hg forget instead of hg remove --after,

like image 112
Ry4an Brase Avatar answered Oct 11 '22 21:10

Ry4an Brase