Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

is `hg forget` the same as `git rm --cached`?

i'm having a hard time understanding hg forget. is it the same as git rm --cached? i.e. will remove the file with the next commit and stop tracking it?

like image 614
knittl Avatar asked Nov 09 '10 15:11

knittl


1 Answers

hg forget tells mercurial to stop tracking a file, but doesn't alter the file in your working directory.

After your commit it will behave as if you never did a hg add (though of course history will still exist). New clones won't have that file in their working dir, but it won't be deleted in your working dir.

If you want to have a file in the workingdir/manifest, but want to ignore future changes, there's no easy way to do it (because it's generally considered a bad idea), though you can fake it by aliasing things to use -I on hg commit.

The better way to do that is to commit a sample of the file you want in the repo but whose changes you want ignored and then have your build system (or your instructions) copy that to its non-sample location. For example have a file config-file.sample that is tracked in the repo, and then have setup/installation/build do a cp config-file.sample config-file if config-file doesnt' exist. Include config-file in your .hgignore so it doesn't accidentally get added. That gives you a tracked baseline but doesn't risk committing and pushing your local customizations. This is very commonly done for things like database paths.

like image 63
Ry4an Brase Avatar answered Oct 17 '22 04:10

Ry4an Brase