If you are using cygwin and experiencing this issue, I have learned of a solution that doesn't require changing your git settings. First, be aware that this is a known issue but it is not planned on being fixed. After a bunch of research, I found this gist: https://gist.github.com/nickbudi/4b489f50086db805ea0f3864aa93a9f8 It consists of two files.
cygpath-git-editor.sh:
#!/bin/bash
# wrapper to convert linux paths to windows
# so vscode will work as a git editor with cygwin
# editor="/home/this/file.sh" in .gitconfig
# extract last argument (the file path)
for last; do true; done
# get all the initial command arguments
all="${@:1:$(($#-1))}"
# launch editor with windows path
code $all $(cygpath -w $last)
cygpath-git-vscode.bat:
@echo off
REM wrapper to convert linux paths to windows
REM so vscode git integration will work with cygwin
REM "git.path"="C:\\this\\file.bat" in settings.json
setlocal
set PATH=C:\cygwin\bin;%PATH%
if "%1" equ "rev-parse" goto rev_parse
git %*
goto :eof
:rev_parse
for /f %%1 in ('git %*') do cygpath -w %%1
I will now explain the steps to use these scripts:
Copy and paste the scripts to your local file system.
In cygpath-git-vscode.bat, change set PATH=C:\cygwin\bin;%PATH%
to the correct path on your system. For me, that meant setting it to set PATH=C:\cygwin64\bin;%PATH%
Run chmod +x <filename>
on each file. If you forget this step, you'll get a vague error about the command not being found.
Edit your visual studio code settings.json and set git.path
to the windows path to cygpath-git-vscode.bat. e.g.,
"git.path": "C:\\cygwin64\\home\\user\\cygpath-git\\cygpath-git-vscode.bat"
Restart visual studio code.
After those steps, only the modified files showed as modified in VS Code.
git status
tell you? – Michelmichelangelogit status
displays the same list of files and says it is modified – Impostorgit diff
– Paddockgit diff
gives the correct output. It only displays files that are actually modified. – Impostor