git add, commit and push commands in one?

前端 未结 30 1454
隐瞒了意图╮
隐瞒了意图╮ 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条回答
  •  萌比男神i
    2020-12-02 03:55

    If you're using a Mac:

    1. Start up Terminal Type "cd ~/" to go to your home folder

    2. Type "touch .bash_profile" to create your new file.

    3. Edit .bash_profile with your favorite editor (or you can just type "open -e .bash_profile" to open it in TextEdit).

    4. Copy & Paste the below into the file:

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

    After this, restart your terminal and simply add, commit and push in one easy command, example:

    lazygit "This is my commit message"
    

提交回复
热议问题