I am trying to train myself to write better commit messages, so I have created an entry in my ~/.gitconfig
[commit]
template = ~/.gitmessage.txt
The conundrum is that I nearly always use:
git commit -m "Message here"
and sometimes:
git commit -am "Message here"
How can I prevent myself from using the -m flag, so that my template will be presented and I will be reminded to use it?
I don't need to absolutely enforce this in the project, but I would like to wean myself off of "-m".
Ubuntu/Bash is my environment.
sslVerify false to disable SSL verification if you're working with a checked out repository already.
The trick to prevent accidentally pushing in-development changes to the wrong environment is to use the git command for changing remote's URL. By adding the --push flag to the command, only the push URL is manipulated. So it is still possible to pull from that remote.
Put this in your .bashrc
:
git() {
for arg
do
if [[ $arg == -m* || $arg == -[^-]*m* ]]
then
annoy_me
return 1
fi
done
command git "$@"
}
annoy_me() {
echo "Stop using -m, $USER!"
echo "You are now in time out."
settings=$(stty -g)
stty raw
sleep 15
stty "$settings"
}
annoy_me
here waits 15 seconds and is not killable from that terminal.
You can replace it by whatever you consider suitably annoying, such as sl
or mplayer -volume 100 Spice_Girls_Wannabe.mp3 < /dev/null &> /dev/null &
You can write a shell script called git
as well and put it into your PATH before the real git. Inside it, you just check the args for -m, if present scoff at yourself, if not call the real git binary.
See this question for an example how to forward the args.
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