I confess that I sometimes use git commit -a when I should not. It's gotten to be reflex about half the time, often when I think I'm working in separate repositories - but I'm actually working in a much larger one that will affect directories far and wide.
Is there a .git/config setting I can specify that will cause the -a flag to throw an error?
Thanks to VonC, I hacked up a function I stuck in my rc file:
git() {
if [[ ($1 == "add") || ($1 == "stage") || ($1 == "commit") ]]; then
if [[ $@ == *-a* ]]; then
echo "Don't use 'git $1 -a'.";
else
command git "$@";
fi
else
command git "$@";
fi;
}
Is there a .git/config setting I can specify that will cause the -a flag to throw an error?
Not that I know of.
You would need a wrapper for git which would check the arguments ("commit", "-a", ...), and on the specific command "commit -a" would throw an error.
Jubobs' script (mentioned in the comment above) is a good example of such a wrapper.
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