Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to do Mercurial's 'hg remove' for all missing files?

Tags:

mercurial

People also ask

How to remove files from hg?

' hg forget ' is just shorthand for ' hg remove -Af '. From the ' hg remove ' help: ...and -Af can be used to remove files from the next revision without deleting them from the working directory. Bottom line: ' remove ' deletes the file from your working copy on disk (unless you uses -Af ) and ' forget ' doesn't.

How to untrack files in hg?

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 exclamation mark mean in mercurial?

As @Riley pointed out, it means they're missing. An alternative method of removing them from the repository is to use hg remove --after <filename> .


This will add all new files that are not ignored, and remove all locally missing files

hg addremove

Either of these will remove all locally missing files(They are the same command)

hg remove --after
hg remove -A

If you intend to do addremove and commit, it can be joined with '-A' option as shown here:

hg commit -A -m 'Commit with addremove'

The original question asked how to remove (i.e. forget) files that show up as "!" when using hg st. A direct approach which has the advantage of transparency is to use hg st with the -n option:

hg -v forget $(hg st -nd)

(Of course the files will only be forgotten at the next commit.)

The flags are well-documented elsewhere (e.g. by the hg command itself), but in brief:

  • -n means "filename only"
  • -d means "select files that have been deleted"

If you want to addremove and commit, but are not ready to commit the rest of your changes, I think you still have to enumerate them:

$ hg st
M modified-file
A added-file
R removed-file-1
R removed-file-2

$ hg commit -m"remove removed-file-1 and removed-file-2" removed-file-*
abort: removed-file-*: No such file or directory

$ hg commit -m"remove removed-file-1 and removed-file-2" removed-file-1 removed-file-2
committed changeset 185:628800a7af84