Can you remove a file from Mercurial without removing it from the filesystem like Git?

16,377

Solution 1

You can use hg forget <file> if files have just been added, however if the files have already been committed use hg rm --after <file>.

The help is a bit misleading, it should be hg rm --do-not-touch-the-filesystem.

Solution 2

It looks like hg forget is what I was looking for according to this.

This will mark a file so that it is no longer tracked after the next commit.

Solution 3

If you need to remove the file from Mercurial history as well, here's a stackoverflow question on how you do this: https://stackoverflow.com/questions/3558365/mercurial-remove-file-from-all-changesets/

Share:
16,377

Related videos on Youtube

ghickman
Author by

ghickman

Engineer with a passion for building APIs and distributed systems, riding bikes and all things sci-fi/fantasy.

Updated on September 17, 2022

Comments

  • ghickman
    ghickman almost 2 years

    I've got some files in a repo that I don't want tracked, is it possible to remove them without removing the actual files from the filesystem?

    This would be equivalent to git's rm --cached.

  • ghickman
    ghickman over 13 years
    I've ignored them but they're already tracked in the repo and have changes so are showing up.