git add, commit and push commands in one?

前端 未结 30 1496
隐瞒了意图╮
隐瞒了意图╮ 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条回答
  •  执念已碎
    2020-12-02 04:02

    If you're using fish shell (building off of btse's answer):

    Save this file within '~/.config/fish/functions' as 'quickgit.fish'. Create the directory if it does not exist. '--git-dir=$PWD/.git' Ensures that we run the git commands against the git project where we called the function

    function quickgit # This is the function name and command we call
        git --git-dir=$PWD/.git add . # Stage all unstaged files
        git --git-dir=$PWD/.git commit -a -m $argv # Commit files with the given argument as the commit message
        git --git-dir=$PWD/.git push # Push to remote
    end
    

    Restart terminal, navigate to project, make changes, and now you can call 'quickgit "example message"'. Changes will now be added, committed, and push :).

    Also can be found as a Gist here: https://gist.github.com/Abushawish/3440a6087c212bd67ce1e93f8d283a69

提交回复
热议问题