0

Got a weird problem with undo in VS2015 when working in a Git repo. Change e.g. 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: enter image description here

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.

jaspernygaard
  • 3,098
  • 5
  • 35
  • 52
  • This looks more like VS simply doesn’t refresh its status view. Can you try having the diff view closed as you undo the change? Also, what happens when you click the refresh button in the team explorer panel? – poke Dec 21 '16 at 13:16
  • Closing the diff view has no impact and the same goes for the refresh button. – jaspernygaard Dec 22 '16 at 08:40

2 Answers2

0

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
LeGEC
  • 46,477
  • 5
  • 57
  • 104
0

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.

Community
  • 1
  • 1
jaspernygaard
  • 3,098
  • 5
  • 35
  • 52