简体   繁体   中英

Git is unable to access jarfile on Windows. No backslash characters are showing up in file path

I'm trying to integrate a checkstyle.xml file into a pre-compile git hook.

I successfully ran the command

git config --add checkstyle.xml C:\Users\<user>\Documents\<App-Name>\CheckStyle\checkstyle.xml 

However, now when I try to commit I get the following error:

Error: Unable to access jarfile C:Users<user>Documents<AppName>...

Notice that the backslashes don't exist. I looked at the git config file and each backslash has another backslash in front of it as an escape character.

Does git not recognize any backslashes? I tried adding the file with forward slashes instead of back and I get that the jarfile is corrupt. Any help would be appreciated.

edit: Paul Hicks' solution of changing

git config --add C:\mydir\checkstyle.xml

to

git config --add C:\\mydir\\checkstyle.xml

worked.

git understands both slashes and backslashes. To add backslashes, you must escape them. So either of these commands will work.

git config --add checkstyle.jar C:/yourdir/checkstyle.jar
git config --add checkstyle.jar C:\\yourdir\\checkstyle.jar

You can check your configuration by viewing the file .git/config , you should see something like this:

[checkstyle]
        jar = C:/yourdir/checkstyle.jar

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM