Search code examples
pythongitgithubdiffgit-diff

Git Diff Python: Python can't open file. Removes all '\' from directory


When I try to git diff a file using my custom python script I get the error can't open file and shows the directory with all '\' being removed.

.gitconfig:

[diff "zip"]
    textconv = python C:\\Users\\user\\Documents\\git-xlsm-project\\xlsm-git-diff-test\\git_diff_xlsm.py

Gives this error when I try to do a git diff:

c:\Python33\python.exe: can't open file 'C:UsersuserDocumentsgit-xlsm-projectxlsm-git-diff-testgit_diff_xlsm.py': [Errno 2] No such file or directory
fatal: unable to read files to diff

Solution

  • Use forward slashes instead and it works. C:/Users/user/Documents/git-xlsm-project/xlsm-git-diff-test/git_diff_xlsm.py