Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git on windows shows modified files all the time, even for newly cloned repo

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

like image 378
pbathala Avatar asked Apr 01 '13 21:04

pbathala


People also ask

How do I remove unchanged files in git?

Remove every file from Git's index. git rm --cached -r .

Which command is used to add new files for tracking?

Tracking New Files The git add command takes a path name for either a file or a directory; if it's a directory, the command adds all the files in that directory recursively.

What is the name of the folder that stores the history of the repository after we clone it?

Git stores the complete history of your files for a project in a special directory (a.k.a. a folder) called a repository, or repo. This repo is usually in a hidden folder called . git sitting next to your files.

How do you git add all?

To add and commit files to a Git repository Enter git add --all at the command line prompt in your local project directory to add the files or changes to the repository. Enter git status to see the changes to be committed.


6 Answers

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.

like image 131
Juuso Ohtonen Avatar answered Oct 01 '22 21:10

Juuso Ohtonen


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

git config --global core.autocrlf true
like image 20
Ruslan Osipov Avatar answered Oct 01 '22 22:10

Ruslan Osipov


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.

like image 36
BoneGoat Avatar answered Oct 01 '22 20:10

BoneGoat


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

like image 35
Gene Pavlovsky Avatar answered Oct 01 '22 20:10

Gene Pavlovsky


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.

I tried adding the above options in git config but it did not help.

You can simply right click on any folder go to

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.

like image 40
NeverGiveUp161 Avatar answered Oct 01 '22 22:10

NeverGiveUp161


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.

like image 22
GlacialSpoon Avatar answered Oct 01 '22 22:10

GlacialSpoon