git add, commit and push commands in one?

前端 未结 30 1460
隐瞒了意图╮
隐瞒了意图╮ 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:00

    I ended up adding an alias to my .gitconfig file:

    [alias]
        cmp = "!f() { git add -A && git commit -m \"$@\" && git push; }; f"
    

    Usage: git cmp "Long commit message goes here"

    Adds all files, then uses the comment for the commit message and pushes it up to origin.

    I think it's a better solution because you have control over what the commit message is.

    The alias can be also defined from command line, this adds it to your .gitconfig:

    git config --global alias.cmp '!f() { git add -A && git commit -m "$@" && git push; }; f'
    

提交回复
热议问题