Mercurial: Mass Add and Remove All Files

By  on  

While I much prefer git and the GitHub workflow, Firefox's codebase (mozilla-central) is store in a mercurial repository.  There are tools that wrap mercurial so you can use a git-like interface, like git-cinnabar, but my philosophy is to learn the root tool so that I know what's going on every step of the way.  Imagine losing work to an abstraction problem -- that would be terrible!

One task you need accomplish is adding and removing files during the commit process, which is easy enough:

# Add file
hg add path/to/file

# Remove missing file
hg remove path/to/file

When there are many files being added and some being removed, you want to be very careful, but adding and removing files one by one can be time-consuming.  Once you've confirmed you want to add new files and remove missing files, you can run the following:

# Add new files, remove missing
hg addremove

If you only want to remove missing files, you can execute the following:

hg remove --after

I know that git branching and mercurial bookmarks are very similar, but I have much less confidence in my mercurial skills, so I'm always ultra careful not to mess up my commits.  Good luck!

Recent Features

Incredible Demos

  • By
    CSS Text Overlap

    One of the important functions of CSS is to position elements. Margin, padding, top, left, right, bottom, position, and z-index are just a few of the major players in CSS positioning. By using the above spacing...

  • By
    MooTools PulseFade Plugin

    I was recently driven to create a MooTools plugin that would take an element and fade it to a min from a max for a given number of times. Here's the result of my Moo-foolery. The MooTools JavaScript Options of the class include: min: (defaults to .5) the...


    Wrap your code in <pre class="{language}"></pre> tags, link to a GitHub gist, JSFiddle fiddle, or CodePen pen to embed!