Wrong path with Git Bash for Windows when using remote add?

那年仲夏 提交于 2019-12-08 04:18:40

问题


I have some bash code like this:

repo="/mnt/shared/my/repo path sometimes with spaces.git"
echo "\$repo = $repo"
git remote add origin "${repo}"
git remote -v

where /mnt/shared is a mountpoint to a network drive created in the git cygwin fstab file that works fine. I can interact with it through the Git bash shell using ls and pushing and pulling repos from it no problem.

I use the above code in a loop to maintain a large set of repos, and if my repo variable is like above without any special characters at all (aside from spaces, which don't affect this situation at all), I get the following output:

$repo = /mnt/shared/my/repo path sometimes with spaces.git
origin //unc-path/to/mountpoint/my/repo path sometimes with spaces.git (fetch)
origin //unc-path/to/mountpoint/my/repo path sometimes with spaces.git (pull)

or

$repo = /mnt/shared/my/repopathnospaces.git
origin //unc-path/to/mountpoint/my/repopathnospaces.git (fetch)
origin //unc-path/to/mountpoint/my/repopathnospaces.git (pull)

BUT, if the repo variable contains any special character that would normally require escaping (again, except for spaces for some reason), then I get the output that I am actually looking for (which I want in the above case too):

$repo = /mnt/shared/my/repo path with [brackets].git
origin /mnt/shared/my/repo path with [brackets].git (fetch)
origin /mnt/shared/my/repo path with [brackets].git (pull)

or

$repo = /mnt/shared/my/repopathwith[brackets].git
origin /mnt/shared/my/repopathwith[brackets].git (fetch)
origin /mnt/shared/my/repopathwith[brackets].git (pull)   

Notice how it kept my /mnt/shared mountpoint in the path? My question is, why in the heck is it converting to the UNC path in the first case (no special characters)? And how can I get it to always maintain the mountpoint relative path here?

I'm using what I believe is the most recent version of Git Bash for Windows, and running uname gives me MINGW64_NT-6.1 if that helps at all.

来源:https://stackoverflow.com/questions/42939075/wrong-path-with-git-bash-for-windows-when-using-remote-add

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!