Visual Studio代码中的Git表示,即使没有更改,文件也会被修改

xdnvmnnf  于 2023-05-15  发布在  Git
关注(0)|答案(7)|浏览(428)

我正在使用Visual Studio Code进行销售团队开发。我对Git作为仓库有一些问题。当我右键单击package.xml并说RetrieveSourceFromOrg时,它将从Org获取所有文件。
问题是git扩展显示文件在服务器上被修改,即使我在本地有一个示例文件。我不想一次又一次地将所有文件推送到我的git仓库,即使没有任何变化。

你知道为什么会发生这种情况,以及如何避免吗?

**更新:**我做了git diff,它提供了正确的输出。它只显示已修改的文件更改。在这种情况下,只有五个。

zaqlnxep

zaqlnxep1#

如果我们使用更改权限,那么我也会遇到这种行为。为了解决这个问题,你可以使用下面的命令。

git config core.filemode false

如果你想申请全球。

git config --global core.filemode false
jvlzgdj9

jvlzgdj92#

我通过执行以下命令解决了这个问题

git config --global core.autocrlf false
6ovsh4lw

6ovsh4lw3#

我必须同时执行上面的filemodeautocrlf选项,另外,
git config core.whitespace cr-at-eol
我在一个带有linux子系统(wsl)的windows系统上,查看一个主要用linux编写的代码库。
我还必须为安装在linux子系统中的git和windows版本的git执行这些选项,因为VSCode使用了一个,但我实际的git命令是输入到linux bash中的。

to94eoyn

to94eoyn4#

如果运行git diff并看到如下输出:

diff --git a/folder/file.tex b/folder/file.tex
old mode 100725
new mode 100614

运行以下命令以修复此问题。

git config --unset core.filemode

如果在VS Code中刷新源代码控制后这仍然不起作用,请同时运行以下命令。

git config --global core.filemode false
yzckvree

yzckvree5#

如果你正在使用cygwin并遇到这个问题,我已经了解到一个解决方案,不需要改变你的git设置。First, be aware that this is a known issue but it is not planned on being fixed.经过大量的研究,我发现了这个要点:https://gist.github.com/nickbudi/4b489f50086db805ea0f3864aa93a9f8它由两个文件组成。

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

现在我将解释使用这些脚本的步骤:
1.将脚本复制并粘贴到本地文件系统。
1.在cygpath-git-vscode.bat中,将set PATH=C:\cygwin\bin;%PATH%更改为系统上的正确路径。对我来说,这意味着将其设置为set PATH=C:\cygwin64\bin;%PATH%
1.对每个文件运行chmod +x <filename>。如果您忘记了这一步,您将得到一个关于未找到命令的模糊错误。
1.编辑Visual Studio代码settings.json,并将git.path设置为cygpath-git-vscode.bat的Windows路径。例如,

"git.path": "C:\\cygwin64\\home\\user\\cygpath-git\\cygpath-git-vscode.bat"

1.重新启动visual studio代码。
在这些步骤之后,只有修改过的文件在VS Code中显示为修改过的。

6jjcrrmo

6jjcrrmo6#

如果你使用的是cygwin bash,你应该知道有一个与此相关的问题,相反,你可以使用git bash for windows,并在vscode中将其设置为默认shell。

cyej8jka

cyej8jka7#

对我来说,这些e命令已经解决了这个问题:

git config --global core.filemode false
git config --global core.autocrlf false
git config --global core.whitespace cr-at-eol

https://git-scm.com/book/en/v2/Customizing-Git-Git-Configuration#:~:text = with%20these%20issues. -,core.autocrlf,-If%20you%E2%80%99re%20programming
https://git-scm.com/docs/git-config#Documentation/git-config.txt-corefileMode

相关问题