10

When I am switching between branches in git, I am seeing that files are changed even though no updates have been made. This has just started happening recently.

$ git status
# On branch dev
nothing to commit (working directory clean)


$ git checkout master
Switched to branch 'master'


$ git status
# On branch master
# Changes not staged for commit:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#       modified:   App.Core/ViewModels/CriteriaViewModel.cs
#       modified:   App.Core/ViewModels/UserManagement/AccountTagsViewModel.cs
#       modified:   App.Core/ViewModels/UserManagement/TagViewModel.cs
#
no changes added to commit (use "git add" and/or "git commit -a")

These are files that I changed on the dev branch, but then added and committed. Any ideas as to what I'm doing that would cause this?

Akash
  • 5,153
  • 3
  • 26
  • 42
Joe
  • 5,389
  • 7
  • 41
  • 63
  • This is particularly strange because you cannot switch branches unless your changes are committed or stashed. Is nothing happening after the switch to `master`? – Tim Mar 19 '14 at 15:05
  • @TimCastelijns - Nothing that I am aware of. – Joe Mar 19 '14 at 15:21
  • Can you close VisualStudio, do ``git clean -f -x -d`` and repeat the switching? – Sergey K. Mar 24 '14 at 14:51
  • 1
    Can you provide a `git diff` and also check if `git diff -w` produces any output? – poke Mar 24 '14 at 22:54

1 Answers1

4

You can check if the difference is in the eol (end of line) characters in those "changed" files.

If it is, make sure your core.autocrlf is set to false:

git config core.autocrlf false

That would avoid any automatic conversion on checkout.

See "git replacing LF with CRLF" for more.

If you need to enforce a consistent eol, use .gitattributes directives, as in "Fixing the line-endings in a Git repository using the .gitattributes file".

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250