I'm using git 1.9.0 on Windows (msysgit) and I have the following alias:
ignore = "!f() { echo $1 >> \"${GIT_PREFIX}.gitignore\"; }; f"
And I use it like so:
$ git ignore /Directory/Subdir/
This should append to my .gitignore
file within the current directory, or create it if it doesn't exist. However for some reason the path I'm passing in is being converted to an absolute path and I'm not sure why:
Here is what is being appended to my .gitignore
:
C:/Program Files (x86)/Git/Docs/Doxygen/html/
Any reason why this is happening?
If I just use the command like so:
$ git ignore Docs/Doxygen/html
It will not convert the path. So it looks like the forward-slash at the beginning is causing some problems in the shell before the parameter is passed to the alias. Encasing it in quotes doesn't fix it either. I'm at a loss!
Tried this:
$ git ignore \/Docs/Doxygen/html/
C:/Program Files (x86)/Git/Docs/Doxygen/html/
Backslash prior to the forward slash does not fix it either.
It's a bug in msysgit I think. I did the same thing in cygwin and look what happens:
$ git ignore /Docs/Doxygen/html/
/Docs/Doxygen/html/
:-(
The conversion rules for msys are documented on the POSIX path conversion page.
An argument with a leading / is converted up to the first /
According to the documentation you should prefix your path with // to have only the first slash undergo the conversion, and convert forward slashes to backslashes:
//foo\bar ➜ /foo/bar ➜ \ converted to /
Try,
$ git ignore "//Directory\Subdir\"
And,
$ git ignore //Directory\\Subdir\\
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With