Is there a way to trigger a hook after a new branch has been checked out in Git?

前端 未结 4 2027
隐瞒了意图╮
隐瞒了意图╮ 2020-11-30 02:27

Is there a way to trigger a hook after a new branch has been checked out in Git?

4条回答
  •  死守一世寂寞
    2020-11-30 02:47

    If one of these hooks won’t do it I’d be amazed:

    https://schacon.github.io/git/githooks.html

    Maybe this one:

    post-checkout

    This hook is invoked when a git-checkout is run after having updated the worktree. The hook is given three parameters: the ref of the previous HEAD, the ref of the new HEAD (which may or may not have changed), and a flag indicating whether the checkout was a branch checkout (changing branches, flag=1) or a file checkout (retrieving a file from the index, flag=0). This hook cannot affect the outcome of git-checkout.

提交回复
热议问题