Windows 上的 git 一直显示修改过的文件,即使是新克隆的 repo
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15752026/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
git on windows shows modified files all the time, even for newly cloned repo
提问by tazo
I am having issues with my git on a windows machine. I always have some git files that are modified in every repo, the files that show as modified are same.
我在 Windows 机器上的 git 有问题。我总是有一些 git 文件在每个 repo 中被修改,显示为修改的文件是相同的。
If I clone a new repo and use tortoisegit to commit I see some files as modified, even if I never touched a single file in the repo. "gitstatus" doesnt show any modifications though
如果我克隆一个新的 repo 并使用 tortoisegit 提交,我会看到一些文件被修改,即使我从未接触过 repo 中的单个文件。“gitstatus”虽然没有显示任何修改
Any help is appreciated. Thanks
任何帮助表示赞赏。谢谢
采纳答案by Juuso Ohtonen
Check if the changes are merely changes in file permissions. This was the reason in my case, both TortoiseGit and Git Extensions displayed unmodified files.
检查更改是否仅仅是文件权限的更改。这就是我的原因,TortoiseGit 和 Git 扩展都显示未修改的文件。
Use git config core.fileMode false
to ignore chmod differences(or directly edit the .git/configfile).
使用git config core.fileMode false
到忽略CHMOD差异(或者直接编辑的.git /配置文件)。
You may also want to set this as the global config with git config --global core.filemode false
.
您可能还想将其设置为全局配置git config --global core.filemode false
。
回答by Ruslan Osipov
It's line endings issue. Set this on your windows machine:
是行尾问题。在您的 Windows 机器上设置:
git config --global core.autocrlf true
回答by BoneGoat
None of the proposed fixes worked for me. However, I had Cygwin installed and TortoiseGit picked up its path when installed. I solved it by installing the official Git package and changed the path in TortoiseGit.
没有一个提议的修复对我有用。但是,我安装了 Cygwin 并且 TortoiseGit 在安装时选择了它的路径。我通过安装官方的 Git 包解决了它并更改了 TortoiseGit 中的路径。
回答by Gene Pavlovsky
If using TortoiseGit with Cygwin git (not officially supported), several extra setup steps should be done:
如果将 TortoiseGit 与 Cygwin git(未正式支持)一起使用,则应完成几个额外的设置步骤:
Select the
[CYGWIN-INSTALL-PATH]\bin-folder
as git.exe folder.Configure the
HOME
environment variable in Windows, so that Cygwin and TortoiseGit are using the same home directory and global git-config. Use the normal Windows notation here (e.g.,C:\Users\USERNAME
). By default, TortoiseGit uses the Windows home directory which is normally located under c:\Users and Cygwin uses its own home directories which are located under[CYGWIN-INSTALL-PATH]\home
.Configure
AutoCrLf
, this is necessary as TortoiseGit and Cygwin Git have different defaults. The default in Cygwin Git istrue
.Go to TortoiseGit the section called
Advanced Settings
and setCygwinHack
totrue
in order to activate cygwin workarounds.Reboot.
选择
[CYGWIN-INSTALL-PATH]\bin-folder
as git.exe 文件夹。HOME
在 Windows 中配置环境变量,以便 Cygwin 和 TortoiseGit 使用相同的主目录和全局 git-config。在这里使用普通的 Windows 符号(例如,C:\Users\USERNAME
)。默认情况下,TortoiseGit 使用通常位于 c:\Users 下的 Windows 主目录,而 Cygwin 使用位于[CYGWIN-INSTALL-PATH]\home
.配置
AutoCrLf
,这是必要的,因为 TortoiseGit 和 Cygwin Git 有不同的默认值。Cygwin Git 中的默认值是true
.转到 TortoiseGit 调用
Advanced Settings
并设置CygwinHack
为的部分true
以激活 cygwin 解决方法。重启。
Step #4 is crucial and resolved the problem for me.
第 4 步至关重要,为我解决了这个问题。
Reference (see Cygwin Gitsection): https://tortoisegit.org/docs/tortoisegit/tgit-dug-settings.html
参考(见Cygwin Git部分):https: //tortoisegit.org/docs/tortoisegit/tgit-dug-settings.html
回答by GlacialSpoon
I just had this problem and for me the fix turned out to be quite simple.
我刚刚遇到了这个问题,对我来说,修复很简单。
Ensure there are no git processes currently running and then delete .git\index.lock
.
确保当前没有 git 进程正在运行,然后删除.git\index.lock
.
After this the modified state of my files were handled correctly.
在此之后,我的文件的修改状态得到了正确处理。
回答by NeverGiveUp161
Just posting it as a answer here because it might help someone else.
只是在这里发布它作为答案,因为它可能会帮助其他人。
If you have Cygwin and Tortoise Git installed, then it will simply show many files when you try to merge the code with 0 lines added and 0 lines removed which is kind of irritating.
如果您安装了 Cygwin 和 Tortoise Git,那么当您尝试合并代码并添加 0 行并删除 0 行时,它只会显示许多文件,这有点烦人。
I tried adding the above options in git config but it did not help.
我尝试在 git config 中添加上述选项,但没有帮助。
You can simply right click on any folder go to
您只需右键单击任何文件夹即可
Tortoise Settings -> General -> Rerun First Time Wizard
Tortoise Settings -> General -> Rerun First Time Wizard
Now here you can change the path to git.exe by pointing to other Git.exe or if you have Gitbash installed you can point to its git.exe also. Just make sure the already existing path should be something from Cygwin/bin/git.exe which should be updated to other git.exe.
现在,您可以通过指向其他 Git.exe 来更改 git.exe 的路径,或者如果您安装了 Gitbash,您也可以指向其 git.exe。只要确保已经存在的路径应该是来自 Cygwin/bin/git.exe 的东西,它应该更新到其他 git.exe。