git Cygwin:无法克隆:“已存在,不是空目录”,但目录不存在

jc3wubiy  于 2023-04-10  发布在  Git
关注(0)|答案(1)|浏览(242)

我遇到了一个奇怪的问题。我想从一个git仓库克隆,但失败了,显然是因为目标目录已经存在并且不为空:

$ git clone --depth=1 --branch "main" https://github.com/papanito/zi.git $HOME/.zi/bin/
fatal: destination path '/cygdrive/c/Users/papanito/.zi/bin' already exists and is not an empty directory.

但我可以确认,目录并不存在

$ ls -al $HOME/.zi/
ls: cannot access '/cygdrive/c/Users/papanito/.zi/': No such file or directory

这是我的/etc/nssswitch.conf

# /etc/nsswitch.conf
#
#    This file is read once by the first process in a Cygwin process tree.
#    To pick up changes, restart all Cygwin processes.  For a description
#    see https://cygwin.com/cygwin-ug-net/ntsec.html#ntsec-mapping-nsswitch
#
# Defaults:
# passwd:   files db
# group:    files db
# db_enum:  cache builtin
# db_home:  /home/%U
# db_shell: /bin/bash
# db_gecos: <empty>

db_home: windows

我发现cygwin其实是在看这里

/cygdrive/c/cygdrive/c/Users/papanito/

如果我检查文件夹.zi

ls -al /cygdrive/c/cygdrive/c/Users/papanito/
total 0
drwxrwx---+ 1 papanito Domain Users 0 Oct 21 15:55 ./
drwxrwx---+ 1 papanito Domain Users 0 Oct 21 15:55 ../
drwxrwx---+ 1 papanito Domain Users 0 Oct 21 15:55 .zi/

不过,$HOME变量看起来很好

echo $HOME
/cygdrive/c/Users/papanito

这里是挂载信息

$ mount
C:/Users/papanito/scoop/persist/cygwin/root/bin on /usr/bin type ntfs (binary,auto)
C:/Users/papanito/scoop/persist/cygwin/root/lib on /usr/lib type ntfs (binary,auto)
C:/Users/papanito/scoop/persist/cygwin/root on / type ntfs (binary,auto)
C: on /cygdrive/c type ntfs (binary,posix=0,user,noumount,auto)
D: on /cygdrive/d type ntfs (binary,posix=0,user,noumount,auto)
h5qlskok

h5qlskok1#

我可以通过执行以下命令来解决此问题

mklink /J C:\cygdrive\c\Users\papanito C:\Users\papanito\

相关问题