Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Undoing last addremove in Mercurial?

Tags:

mercurial

I typed

$ hg addremove

but later realized that some of the files should not be part of the commit. What I should have done was to add these files to .hgignore and after that run addremove and commit.

Is there a way of fixing this?

like image 625
skeept Avatar asked May 31 '11 05:05

skeept


Video Answer


1 Answers

If you have not commited yet just use hg forget fileToForget or use Tortoise to remove the files.

If you have committed and you don't mind the files to be part of history, just forget them and commit again.

If you don't want them to be part of your repository history, and if commiting them is the very last operation you've made, you can try to rollback (use hg rollback or go in the recovery menu in Tortoise). You will have to forget the file and then commit again

If you're dealing with too many files, you can try to automate the task by getting a list of all added files, forgetting them, modify you .hgignore and do the addremove again.

Example of the first step in powershell with no commit made

hg status --added --no-status | foreach-object {hg forget $_};
like image 115
Cédric Rup Avatar answered Sep 29 '22 10:09

Cédric Rup