Local executing hook after a git push?

前端 未结 5 613
南笙
南笙 2020-11-27 11:07

I\'ve looked at the githooks manpage but unless I\'m missing something I don\'t see an option for local, post-push git hooks. I\'d like to have one that updates the api doc

5条回答
  •  旧时难觅i
    2020-11-27 11:41

    I recently came across the same issue. I wanted a hook so that a push from my git submodule would commit the new submodule reference in the 'superproject'.

    As Chris mentioned, the best way is to just use a git alias, like this:

    $ git config alias.xpush '!git push $1 $2 && update-server.sh'
    # (remember the backslash before the ! if your shell requires it)
    

    This adds the following to your .git/config file:

    [alias]
      xpush = !git push $1 $2 && update-server.sh
    

    And so now, if you type:

    $ git xpush
    

    your changes will be pushed, and then update-server.sh will be executed.

提交回复
热议问题