git add, commit and push commands in one?

前端 未结 30 1461
隐瞒了意图╮
隐瞒了意图╮ 2020-12-02 03:15

Is there any way to use these three commands in one?

git add .
git commit -a -m \"commit\" (do not need commit message either)
git push

Som

30条回答
  •  Happy的楠姐
    2020-12-02 03:53

    Building off of @Gavin's answer:

    Making lazygit a function instead of an alias allows you to pass it an argument. I have added the following to my .bashrc (or .bash_profile if Mac):

    function lazygit() {
        git add .
        git commit -a -m "$1"
        git push
    }
    

    This allows you to provide a commit message, such as

    lazygit "My commit msg"
    

    You could of course beef this up even more by accepting even more arguments, such as which remote place to push to, or which branch.

提交回复
热议问题