Git is not able to identify the local .gitconfig of the directory unless marked as a safe directory globally. I have a local .gitconfig set for a directory which is marked as safe inside the local .gitconfig file. But git is not able to identify it as a git directory When I do git config --list --local It says says- fatal: --local can only be used inside a git repository. git version 2.32.0 Any idea?
1 Answers
You cannot use the safe.directory
option in a local config file. The reason is that a repository which has insecure permissions might be tampered with by an attacker, and if that's the case, the attacker could have modified the configuration file in that repository's directory as well. You must use safe.directory
in the global (that is, per-user) or system config files instead. See git config --help
for more information on the option and where it can be used.
Git does have a documented procedure for determining whether a directory is inside a repository and for discovering the repository. It walks the tree looking for one of a bare repository, a .git
directory, or a .git
file (a gitlink) and then performs some additional tests to determine if it's actually a Git repository by checking the HEAD
file and the existence of a config
file.

- 64,793
- 6
- 84
- 100