Reputation: 681
Whenever I run git commit
or git status
, there are some files I never changed before pop up showing modified
. I checkout/revert these files, but it does not work. git diff
also shows no difference.
I notice that whenever I run git checkout
or git revert
on the file I do not changes, its modify time changes.
Is there any way I can revert these unchanged file to the origin state?
Below is my git bash output, I remove some outputs because many files are now in incorrect state. You can see the file 'repositories.config' cannot revert.
Welcome to Git (version 1.9.4-preview20140611)
Run 'git help git' to display the help index. Run 'git help ' to display help for specific commands.
[MyAccount] /d/Git/Tour/Visa/Order/Visa.Order.Main/packages (release)
$ git status
On branch release Your branch is up-to-date with 'origin/release'.
Changes not staged for commit: (use "git add ..." to update what will be committed) (use "git checkout -- ..." to discard changes in working directory)
modified: repositories.config
no changes added to commit (use "git add" and/or "git commit -a")
[MyAccount] /d/Git/Tour/Visa/Order/Visa.Order.Main/packages (release)
$ git checkout .
[MyAccount] /d/Git/Tour/Visa/Order/Visa.Order.Main/packages (release)
$ git status
On branch release Your branch is up-to-date with 'origin/release'.
Changes not staged for commit: (use "git add ..." to update what will be committed) (use "git checkout -- ..." to discard changes in working directory)
modified: repositories.config
no changes added to commit (use "git add" and/or "git commit -a")
Upvotes: 1
Views: 142
Reputation: 681
Finally I found it was the file .gitattributes changed the git behavior. This file includes the below line: * text=auto, which will automatically normailize line endings. So comments this line with '#', everything goes fine. Check http://git-scm.com/docs/gitattributes for more details.
Set to string value "auto"
When text is set to "auto", the path is marked for automatic end-of-line normalization. If Git decides that the content is text, its line endings are normalized to LF on checkin.
Actually there are many things that can affect the git behavior on line endings check. git config: core.autocrlf, core.safecrlf, core.whitespace. If encounter such similar problem, you can check all these aspects.
Upvotes: 1