John John - 1 month ago 12
Git Question

Git switch branch with Visual Studio 2015 causes changes

I have the following scenario:


  1. I create a local branch from master

  2. Work on the local branch, commit changes

  3. Switch to master using the Visual Studio git plugin

  4. Do some changes on master, commit, sync

  5. When I switch back to the local branch I immediately have uncommitted changes on that branch for the files that I edited on master. So if I view changes on those files there are no actual changes but I am guessing that the date modified of the files changed or something.



At first this was a just nuisance, but when you switch back to master, master will have 'ghost' changes for the files edited in the local branch, so if you continue working like this for a while you are spammed with conflicts when merging the two branches and this can lead to loss of work.

Any clues?

Answer

Problem may be with CRLF (how to change line ending settings)

  1. Checkout Windows-style, commit Unix-style line endings Git will convert LF to CRLF when checking out text files. When committing text files, CRLF will be converted to LF. For cross-platform projects, this is the recommended setting on Windows ("core.autocrlf" is set to "true")
  2. Checkout as-is, commit Unix-style line endings Git will not perform any conversion when checking out text files. When committing text files, CRLF will be converted to LF. For cross-platform projects this is the recommended setting on Unix ("core.autocrlf" is set to "input").
  3. Checkout as-is, commit as-is Git will not perform any conversions when checking out or committing text files. Choosing this option is not recommended for cross-platform projects ("core.autocrlf" is set to "false")