开发者

How to forget all removed files with Mercurial

开发者 https://www.devze.com 2022-12-25 00:56 出处:网络
I am new to Mercurial and after a cleanup of the image folder in my project, I have a ton of files showing with ! in the \'hg status\'. I can type a \'hg forget \' for each, but there must be an easie

I am new to Mercurial and after a cleanup of the image folder in my project, I have a ton of files showing with ! in the 'hg status'. I can type a 'hg forget ' for each, but there must be an easier way.

So how can I tell mercurial to forget about all the removed (status = !) files in 开发者_运维知识库a folder?


If you're also okay with adding any files that exist and aren't ignored then:

hg addremove

would a popular way to do that.


With fileset (Mercurial 1.9):

hg forget "set:deleted()"

In general, on Linux or Mac:

hg status -dn | while read file ; do hg forget "$file" ; done

Or, if your shell allows it, if there are not too many files, and if the filenames do not contain spaces or special characters, then:

hg forget $(hg st -dn)

I


You can try:

hg forget -I '*'

in order to include all files in your forget command.


By using the -d flag for status, which displays missing files:

for file in $(hg status -d | cut -d " " -f 2); do echo hg forget $file; done

Run this in the root of your repo, and if you're happy with the results, remove the echo

This has the bonus over the accepted answer of not doing any additional work, e.g. adding a bunch of untracked files.


more shorter instead of

for file in $(hg status -d | cut -d " " -f 2); do echo hg forget $file; done

this

hg status -d | cut -d " " -f 2 | xargs echo hg forget # test case
hg status -d | cut -d " " -f 2 | xargs hg forget # real work
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号