简体   繁体   中英

VS2015, Git and undo

Got a weird problem with undo in VS2015 when working in a Git repo. Change eg web.config and if I undo the change, the content is changed to the unmodified version. However the file still shows up as a changed file, even though there's no changes in the file.

Se screen cast: https://jnus.tinytake.com/sf/MTIwNjg0OF80NjMzMDc1

Using following config: .gitconfig

[core]
    fscache = true
    preloadindex = true
    autocrlf = true

.gitattribute

* text=auto

Any idea why this is happening. I suspect line ending (currently using CRLF), but haven't been able to confirm this.

Example of a git diff: 在此处输入图片说明

UPDATE: I've tried to normalize line endings, without any luck, with the following alias.

git rm --cached -r . && git reset --hard && git commit -a -m 'Normalize CRLF' -n

UPDATE 2: Seems to impact only XML based files like csproj, config etc.

I'd suggest to inspect what git says :

  • using either a shell and git status , or TortoiseGit, see if you have both a staged version and an unstaged version
  • using git diff , see what shows up as modifications

Ok found a solution to fix all line endings (2.4M endings to be exact) in our solution with the above mentioned .gitattribute. And after this, the undo problem is gone.

$ echo "* text=auto" >>.gitattributes
$ rm .git/index     # Remove the index to force git to
$ git reset         # re-scan the working directory
$ git status        # Show files that will be normalized
$ git add -u
$ git add .gitattributes
$ git commit -m "Introduce end-of-line normalization"

From Trying to fix line-endings with git filter-branch, but having no luck

This has really been a PITA, and not a very good first acquaintance with git on Windows/Visual Studio for the team.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM