Batch remove from Mercurial repo

If you did something wrong and created a lot of files in a mercurial repo, you can delete all very quickly with this
hg st | grep ‘^?’ | cut -d ‘ ‘ -f 2 | xargs rm
Be carefully to execute “hg add” for files you intend to keep otherwise you will lose those files forever.


How to display the Mercurial branch name to bash prompt

To have your current branch name in your bash prompt, just add this code into .bash_profile file from your home directory.

[sourcecode language=”bash”]
hgBranch ()
if [ -d .hg ]; then
printf "$1" "$(hg branch)"

export PS1=’${USER}@${HOSTNAME}:\w$(hgBranch " [\033[1;31m(%s)\033[0m]")$ ‘

Ofcourse, after you edit .bash_profile, you must logout and login again to see the changes.

//later edit

If you want to have the same feature in the graphical terminal, you should add the code above in the .bashrc file.

//2nd later edit
You can find a good “how to” for git on LeaseWeb Labs.