git on windows shows modified files all the time,

2019-03-10 22:06发布

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.

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

Any help is appreciated. Thanks

5条回答
甜甜的少女心
2楼-- · 2019-03-10 22:53

It's line endings issue. Set this on your windows machine:

git config --global core.autocrlf true
查看更多
来,给爷笑一个
3楼-- · 2019-03-10 22:53

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.

After this the modified state of my files were handled correctly.

查看更多
来,给爷笑一个
4楼-- · 2019-03-10 22:56

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.

查看更多
神经病院院长
5楼-- · 2019-03-10 22:58

If using TortoiseGit with Cygwin git (not officially supported), several extra setup steps should be done:

  1. Select the [CYGWIN-INSTALL-PATH]\bin-folder as git.exe folder.

  2. 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.

  3. Configure AutoCrLf, this is necessary as TortoiseGit and Cygwin Git have different defaults. The default in Cygwin Git is true.

  4. Go to TortoiseGit the section called Advanced Settings and set CygwinHack to true in order to activate cygwin workarounds.

  5. Reboot.

Step #4 is crucial and resolved the problem for me.

Reference (see Cygwin Git section): https://tortoisegit.org/docs/tortoisegit/tgit-dug-settings.html

查看更多
疯言疯语
6楼-- · 2019-03-10 23:04

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.

Use git config core.fileMode false to ignore chmod differences (or directly edit the .git/config file).

You may also want to set this as the global config with git config --global core.filemode false.

查看更多
登录 后发表回答