git clone fatal: cannot create work tree dir permission denied

44,268

Solution 1

Use sudo

sudo git clone <url>

Solution 2

The error is pretty simple. You don't have permissions on the given directory.

You can do several things but the most simple one is to try and clone the repository vi git bash

# go to any other directory where you have the permissions to write to
cd <some path>
# Check to see if you have permissions:
mkdir dummy
# Now once you have verified that you have write permissions -
# clone the project from the command line
git clone <url>

Once you have cloned the project - open it in IntelliJ's.

Solution 3

After you have checked the directory permission (make sure you've got write access) try the below steps:

cd ~/
mkdir code
cd code
git clone https://github.com/repo-name

Solution 4

One thing is very clear that you don't have permissions on the given directory. So either you can do cloning or simply run the application by selecting Run as Administration as shown in the image.enter image description here

Later on, you can use git clone https://github.com/forcedotcom/EMP-Connector.git

enter image description here

Thank you.

Share:
44,268

Related videos on Youtube

Redrield
Author by

Redrield

Updated on July 05, 2022

Comments

  • Redrield
    Redrield 11 months

    so I'm trying to clone a repository from git, into a folder i know I have write access in.

    I'm trying to clone it using IntelliJ's built in VCS capabilities, and the git bash program from git-scm.com Both of them return the following error:

    fatal: could not create work tree dir '<repo name>' : 
    Permission denied
    

    What am I doing wrong?

    • Redrield
      Redrield about 7 years
      Alright, I figured out what was wrong, the folder that shared a name with the repo had read only on it. But when I tried to change the attributes I was denied permission, even with admin, will I need to make a linux live cd just to remove that folder or what?
    • Andreas Louv
      Andreas Louv about 7 years
      chmod 644 [directory] and chown user:group [directory]?
    • Redrield
      Redrield about 7 years
      chmod gives me permission denied, even as administrator, chown says it can't perform the operation because it is a directory
    • CodeWizard
      CodeWizard about 7 years
      sudo chmod ... or sudo chown <user> ...
    • Redrield
      Redrield about 7 years
      After much pain with Windows' horrible everything I figured it out. chown chose to work my second time around, thanks!
  • Ilya Sazonov
    Ilya Sazonov about 2 years
    As far as I understand OS in the question is not windows
  • joanis
    joanis about 2 years
    Git Bash is a Windows thing, so I think the OS in indeed Windows.

Related