Oliver Gondža
Oliver Gondža

Reputation: 3511

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:

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'

Upvotes: 3

Views: 2128

Answers (2)

Oliver Gondža
Oliver Gondža

Reputation: 3511

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.

Upvotes: 4

Ashutosh Jindal
Ashutosh Jindal

Reputation: 18869

Can you try renaming the existing /tmp and re-creating it in the cygwin installation folder as described in http://cs.nyu.edu/~yap/prog/cygwin/FAQs.html#tmpfiles :

Suggestion 1

Q: After I installed cygwin, and I started it it gives the following messages: bash.exe: warning: could not find /tmp, please create! bash: /etc/profile: Invalid argument bash: /.bash_profile: Invalid argument

A: You need to first create the directory /tmp. Assuming your cygwin root directory is called C:/cygwin, that means you should first create the directory C:/cygwin/tmp.

Suggestion 2

It seems you are using Git Bash for Windows' git executable in Cygwin. It might be worth trying to use the git executable that Cygwin itself provides.

Upvotes: 1

Related Questions