Variable: git-commit-cd-to-toplevel
git-commit-cd-to-toplevel is a customizable variable defined in
git-commit.el.
Value
nil
Documentation
Whether to set default-directory to the worktree in message buffer.
Editing a commit message is done by visiting a file located in the git
directory, usually "COMMIT_EDITMSG". As is done when visiting any
file, the local value of default-directory is set to the directory
that contains the file.
If this option is non-nil, then the local default-directory is changed
to the working tree from which the commit command was invoked. You may
wish to do that, to make it easier to open a file that is located in the
working tree, directly from the commit message buffer.
If the git variable safe.bareRepository is set to "explicit", then
you have to enable this, to be able to commit at all. See issue #5100.
This option only has an effect if the commit was initiated from Magit.
Source Code
;; Defined in ~/.emacs.d/elpa/magit-20260411.1452/git-commit.el
(defcustom git-commit-cd-to-toplevel nil
"Whether to set `default-directory' to the worktree in message buffer.
Editing a commit message is done by visiting a file located in the git
directory, usually \"COMMIT_EDITMSG\". As is done when visiting any
file, the local value of `default-directory' is set to the directory
that contains the file.
If this option is non-nil, then the local `default-directory' is changed
to the working tree from which the commit command was invoked. You may
wish to do that, to make it easier to open a file that is located in the
working tree, directly from the commit message buffer.
If the git variable `safe.bareRepository' is set to \"explicit\", then
you have to enable this, to be able to commit at all. See issue #5100.
This option only has an effect if the commit was initiated from Magit."
:group 'git-commit
:type 'boolean)