Can you remove a file from Mercurial without removing it from the filesystem like Git?
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/
Related videos on Youtube
ghickman
Engineer with a passion for building APIs and distributed systems, riding bikes and all things sci-fi/fantasy.
Updated on September 17, 2022Comments
-
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 over 13 yearsI've ignored them but they're already tracked in the repo and have changes so are showing up.