How do I unadd a not yet committed file I have added?

14,876

Solution 1

Check out this mercurial tip. To cite the link - if you have accidentally added a file, the way to undo that (changing its status from A back to ?, or unknown) is hg revert. For example, if you just ran hg add and realized that you do not want files foo or bar to be tracked by Mercurial:

hg revert foo bar

Solution 2

Either revert or remove can be used to un-add not yet commited stuff. However, they both have other uses too, so for clarity hg forget was (re-)added in 1.3, and despite its name it might be easier to remember.

Solution 3

If you are using a Unix like system i believe the best option is to run

hg status -an0 | xargs -0 hg revert

Share:
14,876
Rahul
Author by

Rahul

Everything in all of my questions and answers are my opinion( and or facts ) and do not in any way, shape, or form represent the opinion or officially stated position of Microsoft, Google , or Kim Jong Il this is fairly obvious when one considers I have no official capacity in any of these organizations.

Updated on June 06, 2022

Comments

  • Rahul
    Rahul about 2 years

    I typed in hg add and I am brand new to mercurial and the result of this was a bunch of dll's exe's pdb's etc all got added Nothing's been committed yet and I basically want to undo the add. the documentation for hg forget is not very clear not sure if that is want I want How do I undo the add before the next commit

    I do have some real files that need adding so after I can undo the add I will use add with the exclude flag
    Thanks

  • Tomislav Nakic-Alfirevic
    Tomislav Nakic-Alfirevic about 14 years
    +1. Would have been better if you also provided the command itself, though.
  • Bozhidar Batsov
    Bozhidar Batsov about 14 years
    I don't like to repeat something already written(professional decease I guess :-) ) - the command is added now.
  • Matt
    Matt over 12 years
    "and despite its name it might be easier to remember."... !!