desktop: Unexpected 'This folder contains files. Git can only clone to empty folders.' error

Describe the bug

On repo search error “This folder contains files. Git can only clone to empty folders.” is shown, but no folder is selected yet

Version & OS

Version 2.6.1 macOS 11.1 (20C69)

Steps to reproduce the behavior

  1. Go to the GitHub Desktop
  2. Click on ‘Add’ -> ‘Clone repository…’
  3. Start typing something in search (to search through your available repositories)
  4. See error at the top (screenshot attached)

Expected behaviour

Error is shown when some folder is selected

Actual behaviour

Error is shown when searching, no folder was selected yet

Screenshots

image

Additional context

I have previously selected custom folder, not using the default in Documents. Already cloned several repos there. This error doesn’t affect behaviour anyhow, new repos can be cloned without any problems. I assume there’s some bug in the logic if showing this error. My main folder is: ~/Projects and it’s selected, when I click a repo in the list to clone, it automatically changes to ~/Projects/my-project

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 19 (1 by maintainers)

Most upvoted comments

I solved this issue by deleting the directory in the local path.

check your path

Did you solve this?

I too got the error when I tried to clone a repo that’s already present on my local machine. I might have cloned it at some point. As its present already and it contains some files, it throws that error.

Check whether the repo you are having problem with exists in your local machine. If it’s there, then try the option Add Local Repository.

This is how I (hopefully) workaround this problem. By simply addressing through the relevant directory, and clicking : Code >> Open with GitHub Desktop

image

You already have Same folder as your repo name in your local machine first delete that folder and try again

Just delete the repos/folers from the local path. Search for Github folder (wherever you have installed it ) and then just delete the repo you are cloning, from your system. Then try cloning again.

The Problem is the local Path.

For example you cloned /labs Then GitHub Desktop wants to put that under /Documents/GitHub/labs

Now you want to clone from a different master repo e.g. biglamp/labs Then GitHub Desktop want to still put that under /Documents/GitHub/labs

Therefore the error is thrown. Which is why you just need to edit the local path folder name to e.g. /Documents/GitHub/labsFORK_biglamp