【发布时间】:2014-02-21 21:48:58
【问题描述】:
我在 Windows (msysgit) 上使用 git 1.9.0,我有以下别名:
ignore = "!f() { echo $1 >> \"${GIT_PREFIX}.gitignore\"; }; f"
我是这样使用它的:
$ git ignore /Directory/Subdir/
这应该附加到我当前目录中的.gitignore 文件,或者如果它不存在则创建它。但是由于某种原因,我传入的路径正在转换为绝对路径,我不确定为什么:
这是附加到我的.gitignore 的内容:
C:/Program Files (x86)/Git/Docs/Doxygen/html/
发生这种情况的任何原因?
编辑
如果我像这样使用命令:
$ git ignore Docs/Doxygen/html
它不会转换路径。因此,在将参数传递给别名之前,开头的正斜杠似乎在 shell 中引起了一些问题。用引号括起来也不能解决它。我很茫然!
编辑#2
试过这个:
$ git ignore \/Docs/Doxygen/html/
C:/Program Files (x86)/Git/Docs/Doxygen/html/
正斜杠之前的反斜杠也不能解决问题。
编辑#3
我认为这是 msysgit 中的一个错误。我在 cygwin 中做了同样的事情,看看会发生什么:
$ git ignore /Docs/Doxygen/html/
/Docs/Doxygen/html/
:-(
【问题讨论】:
-
将路径作为字符串传递时会发生什么?喜欢
git ignore '/Docs/Doxygen/html'? -
我认为使用 MSYS 你需要使用双正斜杠 //Docs/Doxygen/html