push --force-with-lease by default

后端 未结 6 518
[愿得一人]
[愿得一人] 2020-11-29 17:27

I just learned about git push --force-with-lease. It\'s pretty awesome. But, of course, I don\'t use force that often, and so I\'m worried that I might forget a

6条回答
  •  孤街浪徒
    2020-11-29 18:11

    I want to be reminded that I shouldn't use -f, but I don't want to be fooled into believing that -f means --force-with-lease. So this is my take:

    git() {
      if [[ $@ == 'push -f'* ]]; then
        echo Hey stupid, use --force-with-lease instead
      else
        command git "$@"
      fi
    }
    

    Add to your .bash_profile, .bashrc or .zshrc.

提交回复
热议问题