Is it possible to use regular expressions in, e.g., git commit ".*my_file.*"
?
I tried, and it seems to only interpret these as globs. I also tired a regex flag:
git commit -regex ".*my_file.*"`
Throws an error.
Does anyone know of a way to combine regular expressions with Git commands?
Not with Git itself. Git just receives a list of files passed from the shell, so it would be up to your shell to do regular expression matching for files. I do not think bash can do this, but other shells may be able to.
The best way I can think of to do this is using the find command. For example, if you want only python files:
find -type f -regex ".*\.py$" -exec git commit {} -m "committing only and all python files" \;
Can anyone else think of something less unwieldy?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With