Create a Git repository in a network folder

Tech Knowledge
Published on October 28, 2024

Problem

When a Git repository is located in a network folder, the following error may occur:

'git log' exited with code 128: fatal: detected dubious ownership in repository at '//server123/hoge/repo'
'//server123/hoge/repo' is owned by:
	'S-1-5-32-544'
but the current user is:
	'S-1-5-21-513713162-3993655636-169061624-1001'
To add an exception for this directory, call:

	git config --global --add safe.directory '%(prefix)///server123/hoge/repo'
 (\\server123\hoge\repo)

Solution

As shown in the error message, use git config --global --add safe.directory to trust the network folder.

git config --global --add safe.directory '%(prefix)///server123/hoge/repo'