Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I delete all untracked files from my working directory in Mercurial?

Tags:

mercurial

Is it possible to delete all untracked files from my working directory? Let's say I added a bunch of files to my working directory, didn't add them via 'hg add' and now want to get rid of those new files entirely?

I'm on windows, although I'm using PowerShell, so a combined solution is also possible here.

like image 752
Valentin V Avatar asked Sep 29 '22 16:09

Valentin V


People also ask

What does hg purge do?

This extension purges all files and directories not being tracked by Mercurial in the current repository. It'll remove unknown files and empty directories by default. With the --all option, it will also remove ignored files. It keeps added files and (unmodified or modified) tracked files.

What is hg status?

hg status shows the status of a repository. Files are stored in a project's working directory (which users see), and the local repository (where committed snapshots are permanently recorded). hg add tells Mercurial to track files. hg commit creates a snapshot of the changes to 1 or more files in the local repository.


1 Answers

Add the Mercurial Extension called purge. It is distributed by Mercurial.

This extension adds a “purge” command to “hg” that removes files not known to Mercurial. i.e. untracked Files. So your command would be,

hg purge

It is not enabled by default, maybe to avoid accidentally removing files that you forgot to add.

To install this extension, add this to your mercurial settings file (.hgrc on Unix, Mercurial.ini on Windows)

[extensions]
purge = 

To enable this extension temporarily you can use

hg purge --config extensions.purge= 
like image 303
simplyharsh Avatar answered Oct 17 '22 22:10

simplyharsh