Search code examples
windowsgitgithubsparse-checkout

Git clone is not working due to bad file path


Problem

Git cloning the repository on a Windows 10 machine throws this error:

error: invalid path 'saleor/graphql/core/tests/cassettes/test_get_oembed_data[http:/www.youtube.com/watch?v=dQw4w9WgXcQ-VIDEO].yaml'

fatal: unable to checkout working tree

warning: Clone succeeded, but checkout failed.

>git clone https://github.com/mirumee/saleor.git
Cloning into 'saleor'...
remote: Enumerating objects: 187180, done.
remote: Counting objects: 100% (289/289), done.
remote: Compressing objects: 100% (225/225), done.
remote: Total 187180 (delta 136), reused 131 (delta 64), pack-reused 186891
Receiving objects: 100% (187180/187180), 105.28 MiB | 234.00 KiB/s, done.
Resolving deltas: 100% (137187/137187), done.
error: invalid path 'saleor/graphql/core/tests/cassettes/test_get_oembed_data[http:/www.youtube.com/watch?v=dQw4w9WgXcQ-VIDEO].yaml'
fatal: unable to checkout working tree
warning: Clone succeeded, but checkout failed.
You can inspect what was checked out with 'git status'
and retry with 'git restore --source=HEAD :/'

Tried

I tried this approach but it didn't work at the last step:

$ git init saleor
$ cd saleor
$ git remote add origin https://gitzzz.com/yyy/saleor.git -f

So far so good, but this command throws error:

$ git checkout origin/master -f
error: invalid path 'saleor/graphql/core/tests/cassettes/test_get_oembed_data[http:/www.youtube.com/watch?v=dQw4w9WgXcQ-VIDEO].yaml'

Tried

Also, this approach didn't help.

Question

How can I clone/checkout this repo on Windows?

Solution

The option suggested by @bk2204 resolved the issue:

  1. Fork the repository
  2. Clone the fork on Linux
  3. Change the path names on Linux
  4. Commit and push
  5. Then check out the fixed fork on Windows

Solution

  • The problem here is that the path contains both colons and question marks and you're likely on a Windows system. Windows has made a deliberate decision not to allow these characters in path names, so there's no way to check this file out there.

    You have some options:

    • Use a different operating system, like macOS or Linux.
    • Check the file out using the Windows Subsystem for Linux, which doesn't suffer from these limitations.
    • Ask the party responsible for the repository to change the path name or do it yourself in another environment, then check out the fixed repo.
    • Ask Microsoft to fix this problem.
    • Don't use this repo.