简体   繁体   中英

Deleting tracked file from the file system vs hg remove

I'd like to know if there are any consequences when deleting a tracked file from file system (eg via windows explorer) in comparison with when using hg remove to delete it from file system and untrack it.

In both cases, I'll commit afterwards, just in the first case tortoise HG marks the file as missing with exclamation mark, with the second it marks it as clean and ready for removal.

Besides this are there any differences?

If you go the file system path and don't make any other changes to tracked files, hg will give you an error when you try to commit:

nothing changed (1 missing files, see 'hg status')

(This is just a special case of nothing changed .)

If you have changed something else, hg won't complain at that point, but the file's status will continue to show up as missing with hg status . This has the negative effect of cluttering up your (mental) workspace and making it harder to tell at a glance what your working directory's current status is. Moreover, the file remains in the repository and will be restored by hg update for any revisions where it is still being tracked!

hg remove will return an error if the file was already deleted from the filesystem; in this case you should use hg forget to tell Mercurial to stop tracking the file.

If you prefer doing big changes with external utilities (like Windows Explorer), you can use the nifty hg addremove which automatically detects additions and removals. (The downside is that you might remove and untrack accidentally deleted files.)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM