I am using the Visual Studio Code for my salesforce development. I have some issues with Git as a repository. When I right-click on the package.xml and say Retrieve Source From Org, it is getting all the files from Org.
The problem is git extension is showing file is modified on the server even though I have a sample file in my local. I don't want to push all the files again and again to my git repo even when there is no change.
Any idea why this is happening and how to avoid it?
Update: I did git diff and it provides correct output. It only shows file changes that are modified. In this case only five.
If we change the permission using then I also encountered that behavior. In order to overcome from this issue you can use the below commands.
git config core.filemode false
In case you want to apply for the global.
git config --global core.filemode false
I was able to resolve it by executing the following command
git config --global core.autocrlf false
If you run git diff
and see an output such as:
diff --git a/folder/file.tex b/folder/file.tex
old mode 100725
new mode 100614
Run the following command to fix the issue.
git config --unset core.filemode
If this doesn't work after refreshing source control in VS Code, run the following command as well.
git config --global core.filemode false
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.
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