In a git hook is the current working directory guaranteed to be within the git repository?

前端 未结 3 886
日久生厌
日久生厌 2020-12-14 05:17

Experimentally it seems that git hooks get run with the current directory set to be the root of the repository. However, I can\'t see any guarantee about that in the git doc

3条回答
  •  半阙折子戏
    2020-12-14 06:05

    The current answers appear to be outdated. As of 2.9.0, the docs state the following:

    Before Git invokes a hook, it changes its working directory to either the root of the working tree in a non-bare repository, or to the $GIT_DIR in a bare repository.

    https://git-scm.com/docs/githooks/2.9.0

提交回复
热议问题