flopga slays
flopga slays

Reputation: 1017

destination path already exists and is not an empty directory

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.

Upvotes: 99

Views: 559038

Answers (15)

Ntuthuko Hlela
Ntuthuko Hlela

Reputation: 15

Just navigate to files on your pythonanywhere UI, then click files. Delete the relevant directories there.

Upvotes: 0

Ujjwal Kumar
Ujjwal Kumar

Reputation: 1

Just check if there is any folder present in the pwd which has same name as that of the repository that you want to clone. you have to rename that folder in order to clone the repository. This worked for me.

Upvotes: -1

Rafa Alonso
Rafa Alonso

Reputation: 837

For the root folder (and any other)

For those coming here wishing to

  • clone a repository that already has contents

in an

  • existing folder that already contains files/folders

Follow the following steps (in this case for the root folder):

cd /
git init
git remote add origin <your-repo-url>
git pull
git checkout main -f
git branch --set-upstream-to origin/main

Change "cd /" to point to your desired folder


For remote computers requiring sudo

In a remote computer, for the root folder, when not a root user; you may execute sudo --preserve-env=SSH_AUTH_SOCK command to transfer the ssh agent. E.g.:

sudo --preserve-env=SSH_AUTH_SOCK su

or add a file to /etc/sudoers.d with this content:

Defaults    env_keep+=SSH_AUTH_SOCK

Upvotes: 66

Zernation
Zernation

Reputation: 1

I had this issue as well,try deleting the actual file in the computer then try clone again.

Upvotes: -1

The Doctor
The Doctor

Reputation: 1

Besides the error appears because it already contains a git directory in that folder, as other people mentioned above. It also occurs if a folder with the same name as your repository already exists.

Ex:

Repository: github.com/username/myRepo.git

If the folder where "clone" is running contains a myRepo folder, this error is thrown: destination path already [...]

Upvotes: 0

Nikhil Gangadharappa
Nikhil Gangadharappa

Reputation: 36

Multiple ways to do this.

Once you log into your server, below are the commands that you can use.

  1. ls ==> To check the files in the current folder.
  2. ls -a ==> To check hidden files in the current folder.
  3. cd "Folder Name" ==> To move into a folder.
  4. cd ==> To move out of a folder.
  5. rm -r ==> Delete a File.
  6. rm -rf ==> Remove a folder.

So for the issue, use ls and check if you are in the right place to delete the folder. Then use rm -rf " Folder Name". This should delete the folder or you can use rm -r "File name" to delete a file.

Regards, Nikhil

Upvotes: 0

Varun Kumar
Varun Kumar

Reputation: 153

Make a new-directory and then use the git clone url

Upvotes: 3

Farid Chowdhury
Farid Chowdhury

Reputation: 3170

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.

Upvotes: 33

ArpitA
ArpitA

Reputation: 741

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

Upvotes: 6

belards
belards

Reputation: 81

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

Upvotes: 5

boly38
boly38

Reputation: 1955

I got same issue while using cygwin to install nvm

In fact, the target directory where empty but the git binary used was the one from windows (and not git from cygwin git package).

After installing cygwin git package, the git clone from nvm install was ok!

Upvotes: 1

kevin_theinfinityfund
kevin_theinfinityfund

Reputation: 2157

An engineered way to solve this if you already have files you need to push to Github/Server:

  1. In Github/Server where your repo will live:

    • Create empty Git Repo (Save <YourPathAndRepoName>)
    • $git init --bare
  2. Local Computer (Just put in any folder):

    • $touch .gitignore
    • (Add files you want to ignore in text editor to .gitignore)
    • $git clone <YourPathAndRepoName>

    • (This will create an empty folder with your Repo Name from Github/Server)

    • (Legitimately copy and paste all your files from wherever and paste them into this empty Repo)

    • $git add . && git commit -m "First Commit"

    • $git push origin master

Upvotes: 0

Sean Becker
Sean Becker

Reputation: 681

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!

Upvotes: 19

user5777975
user5777975

Reputation:

If you got Destination path XXX already exists means the name of the project repository which you are trying to clone is already there in that current directory. So please cross-check and delete any existing one and try to clone it again

Upvotes: 1

James Knott
James Knott

Reputation: 1578

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.

Upvotes: 8

Related Questions