Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to undo all added files in Mercurial

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?

like image 235
PICyourBrain Avatar asked Mar 27 '13 20:03

PICyourBrain


People also ask

How do I revert a file in Mercurial?

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 Untrack a file in Mercurial?

If you see the help for hg rm --help : hg remove [OPTION]... FILE... Schedule the indicated files for removal from the current branch. This command schedules the files to be removed at the next commit.

What does hg purge do?

This extension purges all files and directories not being tracked by Mercurial in the current repository. It'll remove unknown files and empty directories by default. With the --all option, it will also remove ignored files. It keeps added files and (unmodified or modified) tracked files.


1 Answers

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

  1. Read about filesets in Mercurial.
  2. Use fileset in the hg forget command, something like hg forget "set:added()".
like image 117
Lazy Badger Avatar answered Sep 24 '22 02:09

Lazy Badger