meta data for this page
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| git:issues:safedirectory [2023/07/17 15:57] – niziak | git:issues:safedirectory [2025/07/04 13:51] (current) – niziak | ||
|---|---|---|---|
| Line 15: | Line 15: | ||
| ===== Source of problem ===== | ===== Source of problem ===== | ||
| + | |||
| + | Current user is not owner of git repository directory ('' | ||
| + | |||
| + | * Version 2.30.5 Contains commit: [[https:// | ||
| + | * More security checks were added with v 2.35.2 [[https:// | ||
| + | |||
| ===== Workaround ===== | ===== Workaround ===== | ||
| + | Silence all warning (risky!): | ||
| + | <code bash> | ||
| + | git config --global --replace-all safe.directory ' | ||
| + | </ | ||
| + | |||
| + | NOTE: '' | ||
| + | |||
| + | <file config .gitconfig> | ||
| + | [safe] | ||
| + | directory=* | ||
| + | </ | ||
| + | |||
| + | |||
| + | Silence warning for specified directory: | ||
| + | <code bash>git config --global --add safe.directory / | ||
| + | |||
| + | NOTE1: Multiple config entries can be addedd to add more directories | ||
| + | |||
| + | NOTE2: '' | ||
| + | |||
| + | |||
| + | ==== Workaround using env ==== | ||
| + | |||
| + | Do not use envirnonment **GIT_CONFIG_PARAMETERS**. It is only for internal git use, and format is not published. | ||
| + | |||
| + | For modern git (v2.31.0) it is possible to use new env config syntax: | ||
| + | < | ||
| + | GIT_CONFIG_COUNT=1 | ||
| + | GIT_CONFIG_KEY_0=safe.directory | ||
| + | GIT_CONFIG_VALUE_0=* | ||
| + | </ | ||
| + | See: [[https:// | ||
| + | |||
| + | GIT version changelog: | ||
| + | < | ||
| + | 2.31.0: | ||
| + | Two new ways to feed configuration variable-value pairs via | ||
| + | environment variables have been introduced, and the way | ||
| + | GIT_CONFIG_PARAMETERS encodes variable/ | ||
| + | to make it more robust. | ||
| + | </ | ||
| + | |||
| + | Related GIT commit: | ||
| + | < | ||
| + | f9dbb64fadf599c588a39d2251bb3f9a2f7d572a | ||
| + | </ | ||
| + | |||
| + | ==== Workaround for WSL ==== | ||
| + | |||
| + | <code shell> | ||
| ==== Workaround for Yocto ==== | ==== Workaround for Yocto ==== | ||
| Line 32: | Line 88: | ||
| ==== Workaround for Gitlab CI ==== | ==== Workaround for Gitlab CI ==== | ||
| + | |||
| + | <code bash> | ||
| + | git config --global --add safe.directory ${CI_PROJECT_DIR} | ||
| + | |||
| + | # and if needed, for some submodules | ||
| + | git config --global --add safe.directory ${CI_PROJECT_DIR}/ | ||
| + | </ | ||
| + | |||
| + | |||
| + | |||
| + | Workarounds: | ||
| + | * [[https:// | ||
| + | * [[https:// | ||
| + | |||
| + | |||
| + | **Best workaround: | ||
| + | [[https:// | ||
| + | |||
| + | <file toml config.toml> | ||
| + | [[runners]] | ||
| + | environment = [" | ||
| + | </ | ||
| + | |||
| + | or re-register runner with args: | ||
| + | <code bash> | ||
| + | gitlab-runner register \ | ||
| + | --env " | ||
| + | --env " | ||
| + | --env " | ||
| + | --env " | ||
| + | </ | ||
| + | |||
| + | **Note:** According to [[https:// | ||
| + | < | ||
| + | This can be set globally via the | ||
| + | internal environment variable GIT_CONFIG_PARAMETERS, | ||
| + | GIT_CONFIG_*_KEY/ | ||
| + | have the ownership check. | ||
| + | </ | ||
| + | |||