11

After upgrading to latest tortoise git I get error below. When I commit from the command line, this works without error. I executed the global command but error persist.

Error popup

user1029883
  • 695
  • 7
  • 21
  • Please show the path here. – MrTux Mar 30 '23 at 07:33
  • 1
    Does the path end with a slash? Add an exception without a slash at the end. - The last resort for now would be to add the '*' exception which disables this security check - only do this if you trust all users on your machine. – MrTux Mar 30 '23 at 07:35
  • Path is 'c:/Programming/Projects/DemoProject_V2/' And you meant to add simple '*' as safe directory ? Still get the same error, printout is : git config --global --get-all safe.directory Prints out:'\*' – user1029883 Mar 30 '23 at 15:53
  • @MrTux Can you help ? As I mentioned this works wit git command line and only happened after the latest tortoise git upgrade – user1029883 Apr 04 '23 at 17:20
  • 1
    git config --global --get-all safe.directory should print out * without quotes – MrTux Apr 06 '23 at 09:00
  • That worked , thanks so much ! The quotes and non quotes is the worst confusing thing with git. Some commands need the quotes some not, there should be a consistent way to do this ! – user1029883 Apr 06 '23 at 16:03

3 Answers3

14

MrTux gave the correct answer and but in a comment, I just want to make sure that this is marked as answered.

In .gitconfig (I added it in global) this works:

[user]
    name = <your name>
    email = <your email>
[safe]
    directory = *
user1029883
  • 695
  • 7
  • 21
3

The origin for this "error" is a safety check that was added in Git to address CVE 2022-24765.

Therefore, one needs to put working trees that are on a path not owned by the current user on a safe.directory list.

There seems, however, be an inconsistency between vanilla Git and libgit2 regarding the handling of trailing slashes. For libgit2 to recognize a path correctly as safe, it must not end with a slash.

As a last resort, one can also add the * exception which completely disables this security check - only do this if you trust all users on your machine. .gitconfig (normally located in %HOME% or %HOMEDRIVE%%HOMEPATH%, i.e., your user profile folder, cf. Where is the global git config data stored?) should look like this:

[safe]
    directory = *
MrTux
  • 32,350
  • 30
  • 109
  • 146
  • normally path to .gitconfig file will be C:\Users\MyLogin\.gitconfig . https://stackoverflow.com/questions/2114111/where-is-the-global-git-config-data-stored – mili May 03 '23 at 06:36
2

Also something that worked for me related to above comments.

git config --global --add safe.directory *