Search code examples
windowsgitcygwin

Local Git repository does not exist after successful clone from cygwin bash


When I clone to the directory (that does not exists) referred to via absolute path, git does not complain about anything, report 0 exit code but the directory is not created. Git complies the directory do exist when I retry:

user@host /tmp
$ git clone https://github.com/zandev/shunit2.git /tmp/shunit01
Cloning into '/tmp/shunit01'...
remote: Counting objects: 1219, done.
emote: Total 1219 (delta 0), reused 0 (delta 0), pack-reused 1219
Receiving objects: 100% (1219/1219), 308.20 KiB | 0 bytes/s, done.
Resolving deltas: 100% (657/657), done.
Checking connectivity... done.

user@host /tmp
$ echo $?
0

user@host /tmp
$ ls /tmp/shunit01
ls: cannot access /tmp/shunit01: No such file or directory

user@host /tmp
$ git clone https://github.com/zandev/shunit2.git /tmp/shunit01
fatal: destination path '/tmp/shunit01' already exists and is not an empty directory.

user@host /tmp
$ echo $?
128

The directories does not seem to exist when checked from cygwin, powershell or Windows UI. I have not seen any indication of an error of any kind. The same problem can be observed for Admin account.

I can clone the repo correctly when non-absolute path is used (shunit02, or even ../tmp/shunit02).

Using:

  • Windows 7 Enterprise Ver 6.1 Build 7601 Service Pack 1
  • git 2.5.1.windows.1
  • cygwin 2.3.1-1

EDIT:

The /tmp directory is seen as C:\cygwin64\tmp by windows. I used /tmp as an example, the same happens in /cygdrive/c in fact.

EDIT 2:

I am using Git for Windows. The clone works when using widows path for target like: git clone https://github.com/zandev/shunit2.git 'C:\cygwin64\tmp\shunit4'


Solution

  • This is caused by Git for Windows not accepting cygwin paths, therefore /a/b/c got translated to c:\a\b\c. In fact, that is where the repositories are cloned and it explain why subsequent clone attempts fail. The directory in fact exists, though the real destination is unexpected.

    What will work?

    • Use bash shipped with Git for Windows and their path conventions,
    • Use cygwin git that accept cygwin paths (reportedly, there might be other problems),
    • Use native windows paths: git clone https://github.com/zandev/shunit2.git 'C:\cygwin64\tmp\shunit4',
    • Use relative target names as it seems to work without problems.