How can I combine these git commands?

后端 未结 4 876
孤街浪徒
孤街浪徒 2021-02-09 22:43

I do the following string of commands for git and my fingers are getting tired of typing them. :)

git add .
git commit -m \'Some message\'
git push
cap deploy
         


        
4条回答
  •  悲&欢浪女
    2021-02-09 23:17

    You could define a git alias calling a script

    Since version 1.5.0, Git supports aliases executing non-git commands, by prefixing the value with "!".
    Starting with version 1.5.3, git supports appending the arguments to commands prefixed with "!", too.

    Be defining a function within your alias, you can avoid the explicit call to 'sh -c'

    [alias]
            publish = "!f() { git add . ; git commit -m \"$1\" ; git push ; cap deploy ; }; f"
    

    or, after the suggestion of Pod in his answer:

    [alias]
            publish = "!f() { git commit -a -m \"$1\" ; git push ; cap deploy ; }; f"
    

    (to be tested)

提交回复
热议问题