3

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'

Cœur
  • 37,241
  • 25
  • 195
  • 267
Oliver Gondža
  • 3,386
  • 4
  • 29
  • 49
  • Can you please tell us the permissions on the tmp folder? Also, what is the absolute location of the tmp folder (i.e. what is the output of `cygpath -w -p /tmp` OR if you do `cd /tmp && explorer . ` which folder opens up?) – Ashutosh Jindal Dec 14 '15 at 12:15

2 Answers2

4

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.
Oliver Gondža
  • 3,386
  • 4
  • 29
  • 49
  • Why does not these guys globalized the folder structure throughout all the flavors of OS exists!! really daunting for developer :( – Indrajeet Gour Dec 15 '21 at 07:47
1

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.

Ashutosh Jindal
  • 18,501
  • 4
  • 62
  • 91
  • I do not observe any of the symptoms from the question. However, I have recreated the `/tmp` and the issue persists. – Oliver Gondža Dec 14 '15 at 12:32
  • 1
    thanks, is it worth trying to use the git executable that Cygwin provides instead of the msysgit one to see if the problem is reproducible? – Ashutosh Jindal Dec 14 '15 at 12:35