问题描述
当我克隆到通过绝对路径引用的目录(不存在)时,git不会抱怨任何东西,报告0退出代码,但该目录未创建.当我重试时,Git会符合目录 do 存在:
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
从cygwin,powershell或Windows UI检查时,目录似乎不存在.我还没有看到任何类型的错误的迹象.对于管理员帐户,可以观察到相同的问题.
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.
使用非绝对路径(shunit02
甚至../tmp/shunit02
)时,我可以正确克隆存储库.
I can clone the repo correctly when non-absolute path is used (shunit02
, or even ../tmp/shunit02
).
使用:
- Windows 7 Enterprise Ver 6.1 Build 7601 Service Pack 1
- git 2.5.1.windows.1
- cygwin 2.3.1-1
/tmp
目录在Windows中被视为C:\cygwin64\tmp
.我以/tmp
为例,实际上在/cygdrive/c
中也是如此.
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.
我在Windows上使用Git.当使用寡妇路径作为目标时,克隆将起作用:git clone https://github.com/zandev/shunit2.git 'C:\cygwin64\tmp\shunit4'
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'
推荐答案
这是由 Git for Windows 不接受cygwin路径,因此/a/b/c
已翻译为c:\a\b\c
.实际上,这就是克隆存储库的地方,它解释了为什么随后的克隆尝试失败的原因.该目录实际上存在,尽管实际目的地是意外的.
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.
- 使用 Git for Windows 随附的bash及其路径约定,
- 使用接受cygwin路径的cygwin git(据报道,可能还有其他问题),
- 使用本机Windows路径:
git clone https://github.com/zandev/shunit2.git 'C:\cygwin64\tmp\shunit4'
, - 使用相对目标名称,因为它似乎可以正常工作.
- 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.
这篇关于从cygwin bash成功克隆后,本地Git存储库不存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!