Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I make files with a specific extension be added to a commit automatically?

I'm trying to figure out how to automatically add all files of a certain extension (for example *.tex) to the commit dialogue (the checkbox should already be checked! I don't want to search for the new files every single time)

I tried adding *.tex to the auto-commit list (=comma separated list) but that doesn't do anything.

like image 993
Blub Avatar asked Nov 29 '25 08:11

Blub


1 Answers

Mercurial has so called hooks to do stuff automatically on certain events. See also the hgrc documentation and the Mercurial wiki page on Hooks.

Your task can be done with a pre-commit hook, defined in your repository's hgrc file:

[hooks]
pre-commit = hg add -I "*.tex"

Before a commit, this hook automatically adds all not yet tracked tex files in the root of the repository's current working directory. Adjust the value of the -I option or add more -I options to specify more complex patterns of files to add automatically.

Note: I don't use TortoiseHG, so I cannot say if this hook causes any checkboxes to be pre-selected. Anyway, it should also work if you commit with TortoiseHG.

like image 122
Oben Sonne Avatar answered Dec 01 '25 09:12

Oben Sonne



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!