blob: 577df40223a095b999b38a41df6c3a1cd1252de2 [file] [log] [blame]
Glen Choo8d1a7442022-07-14 21:28:01 +00001safe.bareRepository::
2 Specifies which bare repositories Git will work with. The currently
3 supported values are:
4+
5* `all`: Git works with all bare repositories. This is the default.
6* `explicit`: Git only works with bare repositories specified via
7 the top-level `--git-dir` command-line option, or the `GIT_DIR`
8 environment variable (see linkgit:git[1]).
9+
10If you do not use bare repositories in your workflow, then it may be
11beneficial to set `safe.bareRepository` to `explicit` in your global
12config. This will protect you from attacks that involve cloning a
13repository that contains a bare repository and running a Git command
14within that directory.
15+
16This config setting is only respected in protected configuration (see
Elijah Newrencf6cac22023-10-08 06:45:03 +000017<<SCOPES>>). This prevents untrusted repositories from tampering with
Glen Choo8d1a7442022-07-14 21:28:01 +000018this value.
19
Johannes Schindelin89595552022-03-02 12:23:04 +010020safe.directory::
21 These config entries specify Git-tracked directories that are
22 considered safe even if they are owned by someone other than the
23 current user. By default, Git will refuse to even parse a Git
24 config of a repository owned by someone else, let alone run its
25 hooks, and this config setting allows users to specify exceptions,
26 e.g. for intentionally shared repositories (see the `--shared`
27 option in linkgit:git-init[1]).
28+
29This is a multi-valued setting, i.e. you can add more than one directory
30via `git config --add`. To reset the list of safe directories (e.g. to
31override any such directories specified in the system config), add a
32`safe.directory` entry with an empty value.
33+
Glen Choo60616012022-07-14 21:28:00 +000034This config setting is only respected in protected configuration (see
Elijah Newrencf6cac22023-10-08 06:45:03 +000035<<SCOPES>>). This prevents untrusted repositories from tampering with this
Glen Choo60616012022-07-14 21:28:00 +000036value.
Johannes Schindelin89595552022-03-02 12:23:04 +010037+
38The value of this setting is interpolated, i.e. `~/<path>` expands to a
39path relative to the home directory and `%(prefix)/<path>` expands to a
40path relative to Git's (runtime) prefix.
Derrick Stolee0f85c4a2022-04-13 15:32:31 +000041+
42To completely opt-out of this security check, set `safe.directory` to the
43string `*`. This will allow all repositories to be treated as if their
44directory was listed in the `safe.directory` list. If `safe.directory=*`
45is set in system config and you want to re-enable this protection, then
46initialize your list with an empty value before listing the repositories
47that you deem safe.
Carlo Marcelo Arenas Belónae9abbb2022-05-12 18:00:18 -070048+
49As explained, Git only allows you to access repositories owned by
50yourself, i.e. the user who is running Git, by default. When Git
51is running as 'root' in a non Windows platform that provides sudo,
Carlo Marcelo Arenas Belón6b11e3d2022-06-17 13:23:38 -070052however, git checks the SUDO_UID environment variable that sudo creates
53and will allow access to the uid recorded as its value in addition to
54the id from 'root'.
Carlo Marcelo Arenas Belónae9abbb2022-05-12 18:00:18 -070055This is to make it easy to perform a common sequence during installation
56"make && sudo make install". A git process running under 'sudo' runs as
57'root' but the 'sudo' command exports the environment variable to record
58which id the original user has.
59If that is not what you would prefer and want git to only trust
Carlo Marcelo Arenas Belón6b11e3d2022-06-17 13:23:38 -070060repositories that are owned by root instead, then you can remove
Carlo Marcelo Arenas Belónae9abbb2022-05-12 18:00:18 -070061the `SUDO_UID` variable from root's environment before invoking git.