10

Recently when I open git projects in Android Studio, I receive this error :

Error updating changes: Unsafe repository (`project name` is owned by someone else). To add an exception to this directory, call : git config --global --add safe.directory ...

I know using command line mentioned I can get rid of this, but isn't there any automatic solution?

I have lots of projects and every now and then I face this!

AVEbrahimi
  • 17,993
  • 23
  • 107
  • 210

3 Answers3

19

Check your Git version first:

git version

If it is the recent 2.35.2 or 2.36, you need to set the safe.directory setting, because of CVE-2022-24765.

git config --global --add safe.directory 'Path/To/Repo'

Or you can disable it, but make sure you understand why it is there in the first place.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
0

You need to add SSH into your desktop/laptop.

To create a new SSH follow GitHub Link to Generate New SSH

Once you have added the SSH onto your desktop/laptop, open the .pub file in VS Code or NotePad++. Copy the entire key and paste it in the Key column in your GitHub account.

Once you have completed all the steps don't forget to restart the Android Studio. I have tried and tested the proceducre it works for me.

Raj Kanchan
  • 450
  • 6
  • 11
0

I solve my issue by deleting the gitignore file, misc and vcs.xml file of the current project.

IT Student
  • 13
  • 3