destination path already exists and is not an empty directory

git
211,618

Solution 1

Explanation

This is pretty vague but I'll do what I can to help.

First, while it may seem daunting at first, I suggest you learn how to do things from the command line (called terminal on OSX). This is a great way to make sure you're putting things where you really want to.

You should definitely google 'unix commands' to learn more, but here are a few important commands to help in this situation:

ls - list all files and directories (folders) in current directory

cd <input directory here without these brackets> - change directory, or change the folder you're looking in

mkdir <input directory name without brackets> - Makes a new directory (be careful, you will have to cd into the directory after you make it)

rm -r <input directory name without brackets> - Removes a directory and everything inside it

git clone <link to repo without brackets> - Clones the repository into the directory you are currently browsing.

Answer

So, on my computer, I would run the following commands to create a directory (folder) called projects within my documents folder and clone a repo there.

  1. Open terminal
  2. cd documents (Not case sensitive on mac)
  3. mkdir projects
  4. cd projects
  5. git clone https://github.com/seanbecker15/wherecanifindit.git
  6. cd wherecanifindit (if I want to go into the directory)

p.s. wherecanifindit is just the name of my git repository, not a command!

Solution 2

This error comes up when you try to clone a repository in a folder which still contains .git folder (Hidden folder).

If the earlier answers doesn't work then you can proceed with my answer. Hope it will solve your issue.

Open terminal & change the directory to the destination folder (where you want to clone).

Now type: ls -a

You may see a folder named .git.

You have to remove that folder by the following command: rm -rf .git

Now you are ready to clone your project.

Solution 3

Steps to get this error ;

  1. Clone a repo (for eg take name as xyz)in a folder
  2. Not try to clone again in the same folder . Even after deleting the folder manually this error will come since deleting folder doesn't delete git info .

Solution : rm -rf "name of repo folder which in out case is xyz" . So

rm -rf xyz

Solution 4

This just means that the git clone copied the files down from github and placed them into a folder. If you try to do it again it will not let you because it can't clone into a folder that has files into it. So if you think the git clone did not complete properly, just delete the folder and do the git clone again. The clone creates a folder the same name as the git repo.

Solution 5

What works for me is that, I created a new folder that doesn't contain any other files, and selected that new folder I created and put the clone there.

I hope this helps

Share:
211,618
Admin
Author by

Admin

Updated on July 18, 2022

Comments

  • Admin
    Admin 10 months

    I cloned a git repository but accidentally messed up. So I re-cloned and the message showed up:

    destination path already exists and is not an empty directory

    I've tried deleting folders in my mac with the name of the destination path but it did not work.

    I'm very new to coding so all help would be appreciated.

  • Admin
    Admin almost 5 years
    i deleted the folder but it is still showing up EDIT: ok im an idiot, it didnt delete properly
  • Sean Becker
    Sean Becker almost 5 years
    And if I were to receive the error you're getting, I would go into the projects directory and run rm -rf wherecanifindit, like the other people said. rm removes a file, rm -r removes a directory, and rm -f stops the command line from asking you questions. Put that all together and you get rm -rf
  • Daemon Painter
    Daemon Painter almost 3 years
    He needs to clone, but is trying to clone into a location that is already a git repository. This answer doesn't help with that.
  • Daemon Painter
    Daemon Painter almost 3 years
    The issue at hand is trying to clone a repository in a location which is already a git repository. This answer doesn't help with that.
  • Daemon Painter
    Daemon Painter almost 3 years
    Hello, and welcome to SO. Very much like James Knott's answer the solution is indeed to clone the repository elsewhere.
  • boly38
    boly38 almost 3 years
    @DaemonPainter your comment is often true in many cases, but I don't undertstand why you down vote for the rest. A solution to a given issue is not always one an only one answer, because it's depends of your context. Your action helps nobody.
  • kevin_theinfinityfund
    kevin_theinfinityfund almost 3 years
    @DaemonPainter the question states that they've tried deleting the folders; thus, it's presumed that they are trying to restart after an rm -f path but they still have files they want to commit to an initially empty git repo.
  • Daemon Painter
    Daemon Painter almost 3 years
    True, but the comment posted under this answer by the asker states "I'm an idiot, I didn't delete it properly". To me, it looks like the asker is admitting the proposed solution is to not attempt to clone into an existing repo...
  • Marses
    Marses almost 2 years
    It also comes up when there is no .git folder however. For example, if you make a project folder with PyCharm, you will have an .idea folder. I think what OP needs is a way to "force" git to clone the repo, overwrite or not (although in the above situation overwriting wouldn't even be required).