133

I'm trying to clone my fork of the kivy git, but it's not working. I've made the fork correctly, I believe, but when I type this into my Mac terminal:

git clone https://github.com/mygitusername/kivy.git

I get this error:

fatal: could not create work tree dir 'kivy.: Permission denied

Anyone see what I am doing wrong? Thanks!

AndroidDev
  • 20,466
  • 42
  • 148
  • 239

16 Answers16

165

You should do the command in a directory where you have write permission. So:

cd ~/
mkdir code
cd code
git clone https://github.com/kivy/kivy

For example.

tito
  • 12,990
  • 1
  • 55
  • 75
68

Your current directory does not has the write/create permission to create kivy directory, thats why occuring this problem.

Your current directory give 777 rights and try it.

sudo chmod 777 DIR_NAME
cd DIR_NAME
git clone https://github.com/mygitusername/kivy.git
Jaykumar Patel
  • 26,836
  • 12
  • 74
  • 76
24

In my case what happened was that the user I was using had no ownership over the directory. I simply had to change ownership of the directory to that user. For example if user is ubuntu:

chown ubuntu:ubuntu -R directory-in-question

cd directory-in-question/

git clone <git repo comes here >
Pardeep Dhingra
  • 3,916
  • 7
  • 30
  • 56
8

If you are working in Windows you have to change the permissions of the directory putting full permissions or just write to let github clone the repository. The steps are:

  1. Go To your directory
  2. open properties
  3. go to tab "security"
  4. change the permissions
  5. apply
Jeromy French
  • 11,812
  • 19
  • 76
  • 129
user3550873
  • 81
  • 1
  • 3
8

Assuming that you are using Windows, run the application as Admin.

For that, you have at least two options:

• Open the file location, right click and select "Run as Administrator".

Run Git Bash as Admin

• Using Windows Start menu, search for "Git Bash", and you will find the following:

Git Bash using Windows Start Menu

Then, just press "Run as Administrator".

Gonçalo Peres
  • 11,752
  • 3
  • 54
  • 83
Naveen Mosuru
  • 151
  • 2
  • 5
5

For other Beginners (like myself) If you are on windows running git as admin also solves the problem.

5

I had the same error on Debian and all I had to do was:

sudo su

and then run the command again and it worked.

Axel
  • 3,331
  • 11
  • 35
  • 58
jjust
  • 59
  • 1
  • 2
3

Here is how to change ownership of a directory or a file if you are on WSL2 Ubuntu. You have to set both the user and the group. Here is the command:

sudo chown -R your_username:root path/to/dir

-R is for recursive, which changes the ownership of everything inside path/to/dir. Don't change the group name from root. It should stay your_username:root

Bex T.
  • 1,062
  • 1
  • 12
  • 28
2

The directory in which you are trying to write the file or taking the clone of git repository, it does not has the write permission. That's why this problem is occurring.
Please change the write permission of directory.
Then clone the repository.

Arshad
  • 31
  • 3
2

If you are working on a mac, then this is probably because you don't have permission to write to the directory. When I had this issue, I followed the following steps:

  • Opened the folder in finder -> right-click -> get info -> click on the lock on the bottom right of the pop up window, enter admin password -> then change the Sharing and Permissions to Read and Write for wheel, and everyone -> click lock again to save
1

This does happened also when you are cloning a repo without selecting any working directory. just make sure you did cd into your working directory and i believe it will work just fine.

Nazehs
  • 478
  • 1
  • 10
  • 19
0

You need to ensure you are in a directory in which you have write permission. This might not be the directory in which Git is in once you open the terminal. In my case (Widows 10) I had to use the cd command to change the directory to the root directory (C:) After that it worked just fine.

0

Cloning software into a directory using elevated privileges ie root or sudo is considered a security risk.

You can check to ensure you are in a directory in which you have write permission.(non system) this is probably the directory in which Git is being called from and git is just being decent here by complaining ;-)

Try the following steps for a quick painless solution :-)

1.open the terminal;

2.cd /<desired directory>

3.git clone <git-repo>

This does happened also when you are cloning a repo to your local machine without selecting any working directory. just make sure you did cd into your working directory.

-1

For me it was turning off Realtime Protection on the Virus and Threat Protection on Windows.

-2

All you need to do is Run your terminal as Administrator. in my case, that's how I solve my problem.

Joel Meza Baca
  • 658
  • 9
  • 13
-3
sudo chmod 777 DIR_NAME
cd DIR_NAME
git clone https://github.com/mygitusername/kivy.git

should work fine

wwkudu
  • 2,778
  • 3
  • 28
  • 41