禁用-m在混帐 [英] Disable -m in git

查看:135
本文介绍了禁用-m在混帐的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想训练自己写出更好的提交信息,所以我创建了一个条目我的〜/的.gitconfig

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"

有时:

git commit -am "Message here"

如何从使用-m标志,让我的模板将是presented,我会提醒使用它prevent自己?

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?

我并不需要在项目实施绝对,但我想自己戒掉过的-m。

I don't need to absolutely enforce this in the project, but I would like to wean myself off of "-m".

Ubuntu的/ Bash是我的环境。

Ubuntu/Bash is my environment.

推荐答案

将这个你的的.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 在这里等待15秒,是不是从终端killable。

annoy_me here waits 15 seconds and is not killable from that terminal.

您可以通过任何你认为合适的烦人,如更换 SL mplayer的-volume 100 Spice_Girls_Wannabe.mp3<的/ dev / null的&安培;>的/ dev / null的&安培;

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 &

这篇关于禁用-m在混帐的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆