I'm running Windows 7, and I have the latest version of git (2.7.2.windows.1). I previously used Windows PowerShell as my terminal for git operations, with no issues. Recently, I decided to switch to Git Bash, but I'm having one major issue.
My project has a directory (within which are many subdirectories) whose name is simply an underscore. Whenever I try to run git diff
on a file within that directory, I get the following error:
$ git diff _/css/templates/jquery.tag-editor.css
fatal: Invalid object name '_C'.
As far as I know, an underscore is a perfectly valid character in a file/directory name, and tab completion works fine within that directory, so I know the terminal can "see" inside it. Additionally, other contributors to the project, all of them running OSX, do not have this problem. And when I run a simple git diff
, without specifying any single file, it works fine, and happily includes the diff for any changed files within the underscore directory. It also works if I cd
into the underscore directory and run the git diff
from there, so that the path I pass to it does not include the underscore.
What exactly is happening here to prevent me from running git diff
on these files? And where does the "C" come from in the error message when I try to do so?
Update
When I run git checkout -- _/css/templates/jquery.tag-editor.css
to discard the changes to that file, this is the error I see:
error: pathspec '_C:/Program Files/Git/css/templates/jquery.tag-editor.css' did not match any file(s) known to git.
C:\Program Files\Git
is directory of my Git installation. So apparently part of the path is being interpreted as referring to the Git installation directory? Again, what is causing this to happen?
The problems you are experiencing are based on the Posix Path conversions of MinGW/Msys2.
git diff _//css/templates/jquery.tag-editor.css
or use backslashes (which need to be escaped in git-bash):git diff _\\css\\templates\\jquery.tag-editor.css
or prependMSYS_NO_PATHCONV=1
:MSYS_NO_PATHCONV=1 git diff _/css/templates/jquery.tag-editor.css
git diff _\css\templates\jquery.tag-editor.css
OR double a slash as for git-bashin order to prevent the conversion.