Failed to clone local repository with Git(exit code 128)

This article can be read in about 3 minutes.
PR

The purpose 

This page describes how to resolve an error (exit code 128) encountered while attempting to clone a local Git repository on Windows. The detailed error log is provided below.

git.exe clone --progress -v -- "F:\PATH" "F:\PATH"
Cloning into 'F:\PATH'...
fatal: detected dubious ownership in repository at 'F:\PATH'
'F:\PATH' is on a file system that does not record ownership
To add an exception for this directory, call:

git config --global --add safe.directory 'F:PATH'
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.


git did not exit cleanly (exit code 128) (828 ms @ 2024/10/20 16:26:10)

PATH and the redacted portion represent the path to either your local repository or the path you attempted to clone.

PR

Solution

It’s basically the same as the article below.

Save the following as a .bat file in the repository’s source folder and double-click to run it.

(Refer to the article above for more details.)

set "current_dir=%~dp0"
set "m_dir=%current_dir:\=/%"
set "m_dir2=%m_dir:~0,-1%"

git config --global --add safe.directory %m_dir2%

pause
PR

Restult

We can now clone the repository that was failing before. 

comment

Copied title and URL