Bradley Uffner
Bradley Uffner

Reputation: 16991

Visual Studio 2022 shows git repo as "Untrusted"

Visual Studio 2022 has started showing one of my git repos as "Untrusted". What does this mean? How can I fix it?

enter image description here

Upvotes: 25

Views: 11352

Answers (1)

jessehouwing
jessehouwing

Reputation: 114847

This is a new security feature in Git to prevent people from sticking things into a shared git repo to infect your PC. It may have been a bit overboard, but now we'll have to deal with it in every tool on our PCs that use Git:

Why oh Why?

This change in Git came about due a security issue which allows parent repositories directories to override permissions of child repositories in some situations which would potentially allow execution of commands with unintended consequences. You can read more detail about the specific vulnerability here:

Git Security Issue: CVE-2022-24765

Quick Fixes

There are a number of solutions for this problem.

  • git config --global --add safe.directory <Git folder>

  • Manually adding an entry to the git config:

    [safe] 
       directory = d:/projects/path
    
  • Developer Tools can set Safe Repo Status, click view details in the yellow information bar:

     enter image description here

  • Change Folder Ownership. In the File System properties on your machine, change the owner of the directory to be your user.

For details see here.

Upvotes: 30

Related Questions