Failed to clone the repository in GitHub for Windows

failed-to-clone-the-repository-please-check-your-internet-connection

I recently installed GitHub for Windows for the first time so I could compile an open source project. While trying to clone the repository, I got this error:

failed to clone the repository ‘whatever’
Please check your internet connection.

I knew my internet connection was working. A web search revealed answers that didn’t apply or didn’t work for me (an issue that was resolved in an earlier version, and an issue that was fixed by re-installing).

Other descriptions of the problem seemed to happen right at the beginning of the clone operation, or somewhere in the middle. For me it happened at the very end, every time.

Also, if I tried to clone the repo again after the failed attempt, it would take a long time comparing all the files, and then tell me there were thousands of uncommitted files.

So I told GutHub for Windows to stop tracking the repo, and then manually deleted the folder before my many re-attempts.

Using Git Shell

GitHub for Windows configures a Git Shell for you, which seems to be a pre-configured version of an existing shell. For me, it defaulted to PowerShell (other options were Cmd, Git Bash, and Custom). The following steps should work with any shell.

I figured I’d try to clone the repo using the command line. To do this, find Git Shell on the start menu and open it. It should start in your default storage directory (more on this later).

First, get the clone URL. This will be on the right side of the GitHub repo’s web page, like so:

GitHub HTTPS Clone URL

The command to clone a repo from GitHub is:

git clone https://github.com/project/project.git

Note: do this in the directory that will be the parent of your project. Git will create the project directory for you.

In the following screen shot, you’ll see my failed attempt. My default storage  directory is C:\Users\Briantist\Documents\GitHub (the default that GitHub for Windows chose).

Git Shell Clone Repo

I got errors that it was unable to create a few files:

error: unable to create file very/long/path/name (no such file or directory)

As well as:

fatal: unable to checkout working tree
warning: Clone succeeded, but checkout failed

Default Storage Directory and Path Name Length

You might be seeing the problem already. That very long path name is not too big by itself, but when added to the default data directory it seems to be exceeding what Windows can handle.

I simply changed the default storage directory in GitHub for Windows to C:\GitHub to keep it nice and short. This is in under tools (gear icon) > Options. After that I had no issues.

I suspect that this problem will affect .NET projects more than most because of the long names used in some of the files.

It was just my luck that the first repo I tried to clone contained such long file names. I hope this post helps someone else save the hour+ it took me to figure it out.

Comments

  1. I was getting this problem and discovered that if I shut down Skype which was running at the time it worked fine. Weird!

  2. Hi, for me best method was to wacth at log (can access it by “about button”, bottom of page “see logs”), there you can find git embedded exe path. then in etc/gitconfig file, set [http]
    proxy = http://yourproxyaddr:port

  3. You can use Long Path Tool as well, it works good!

    • Seems like Long Path Tool might help you remove some of the created files if they’re stuck there. How would you use it to create a usable repo though?

  4. If you are using a proxy, you need to add a line in your .gitconfig file (probably in your user folder).
    [http]
    proxy = http://your-proxy:8080

  5. In the native GitHub Windows app it’s impossible to make it work right now. Maybe later they’ll create a fix for it. In the meantime you can use http://www.cygwin.com/ which works perfectly under Windows with long paths.

  6. Thanks for this article, I was going with similar problem now solved. thanks again

  7. Resolved by the proxy setting in the http section of gitconfig under C:\Users\{userid}\AppData\Local\GitHub\PortableGit_6d98349f44ba975cf6c762a720f8259a267ea445\etc

    Thanks John!

Speak Your Mind

*