meta data for this page
  •  

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
git:issues:safedirectory [2023/07/17 16:05] niziakgit:issues:safedirectory [2025/07/04 13:51] (current) niziak
Line 16: Line 16:
 ===== Source of problem ===== ===== Source of problem =====
  
-GIT version changelog: +Current user is not owner of git repository directory (''.git'').
-<code> +
-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/value pairs has been tweaked +
-      to make it more robust. +
-</code>+
  
-Related GIT commits+  * Version 2.30.5 Contains commit[[https://github.com/git/git/commit/8959555cee7ec045958f9b6dd62e541affb7e7d9|setup_git_directory(): add an owner check for the top-level directory]], See release notes: [[https://github.com/git/git/blob/aa9166bcc0ba654fc21f198a30647ec087f733ed/Documentation/RelNotes/2.30.5.txt|2.30.5.txt]] 
-<code> +  * More security checks were added with v 2.35.2 [[https://github.blog/2022-04-12-git-security-vulnerability-announced/|Git security vulnerability announced]]
-f9dbb64fadf599c588a39d2251bb3f9a2f7d572a  2021-01-12 13:27 +0100 Jeff King config: parse more robust format in GIT_CONFIG_PARAMETERS +
-</code>+
  
  
  
-So old+===== Workaround =====
  
-<file c environment.h+Silence all warning (risky!): 
-#define CONFIG_DATA_ENVIRONMENT "GIT_CONFIG_PARAMETERS" +<code bash> 
-#define CONFIG_COUNT_ENVIRONMENT "GIT_CONFIG_COUNT"+git config --global --replace-all safe.directory '*' 
 +</code
 + 
 +NOTE: ''*'' is not glob pattern. It is only special value which turns off warning for all dirs. ([[https://github.com/git-for-windows/git/issues/3809#issuecomment-1102681740|The command doesn't interpret the wildcard * as an operator]]) 
 + 
 +<file config .gitconfig> 
 +[safe] 
 +    directory=*
 </file> </file>
  
-===== Workaround ===== 
  
-Add directory with +Silence warning for specified directory
 +<code bash>git config --global --add safe.directory /home/john/project</code>
  
 +NOTE1: Multiple config entries can be addedd to add more directories
 +
 +NOTE2: ''safe.directory'' points only to one specified directory. It doesn't propagate to subdirectories.
 +
 +
 +==== Workaround using env ====
  
 Do not use envirnonment **GIT_CONFIG_PARAMETERS**. It is only for internal git use, and format is not published. Do not use envirnonment **GIT_CONFIG_PARAMETERS**. It is only for internal git use, and format is not published.
  
-Set following env variables (NOTE: supported from GIT **v2.31.0**):+For modern git (v2.31.0) it is possible to use new env config syntax:
 <code> <code>
 GIT_CONFIG_COUNT=1 GIT_CONFIG_COUNT=1
Line 52: Line 56:
 GIT_CONFIG_VALUE_0=* GIT_CONFIG_VALUE_0=*
 </code> </code>
 +See: [[https://git-scm.com/docs/git-config#Documentation/git-config.txt-GITCONFIGVALUEltngt|GIT_CONFIG_VALUE_]]
 +
 +GIT version changelog:
 +<code>
 +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/value pairs has been tweaked
 +      to make it more robust.
 +</code>
 +
 +Related GIT commit:
 +<code>
 +f9dbb64fadf599c588a39d2251bb3f9a2f7d572a  2021-01-12 13:27 +0100 Jeff King config: parse more robust format in GIT_CONFIG_PARAMETERS
 +</code>
 +
 +==== Workaround for WSL ====
  
 +<code shell>git config --global --add safe.directory '%(prefix)///wsl$/Ubuntu-22.04/home/username/code/my-repo-name'</code>
  
 ==== Workaround for Yocto ==== ==== Workaround for Yocto ====