Reputation: 10284
Say I type hg add
in Mercurial, and there a bunch of untracked files in my working directory that are not ignored. What is the easiest way to un-add all those files without explicitly typing the name of each file?
Can I just un-add them all with one command?
Upvotes: 31
Views: 19912
Reputation: 41
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. I don't know why .^ works yet, but somebody will probably know.
Upvotes: 0
Reputation: 97282
Preface
You must always ask questions, which contain as much information as possible. Because now your question, depending from some conditions, may have totally different answers.
Case One - no local modifications in already versioned files, only added (and not committed) files
hg revert
will return your working directory to the state after the last commit, undoing all changes it it.
Case One - local edits, which you want to save and occasionally added files
hg forget
command, something like hg forget "set:added()"
.Upvotes: 31
Reputation: 73778
Use hg revert
or hg forget
on the files (both do the same for a file you ran hg add
on). To avoid typing out the filenames, you can use a fileset like this:
$ hg revert "set:added()"
This will revert the file back to how it looked in the working copy parent revision, i.e., it will become unknown again.
Upvotes: 30
Reputation: 8078
You could always just re-clone your repository and then replace (delete existing and then copy new) the .hg directory in your working folder with the one from the fresh clone... (assuming you have no pending commits..)
Upvotes: -2