开发者

Undoing last addremove in 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 thi开发者_C百科s?


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 $_};


To undo an addremove you did not commit yet simply run:

$ hg revert --all
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜