Dan Ramos
Dan Ramos

Reputation: 1102

Git checkout remote branch creates locally modified files

I'm working on the trunk of a project locally and need to checkout a remote branch. My working copy is fully up-to-date, and i run

git checkout -b RC1 origin/RC1

After that I run

git status

And it tells me I have about 30 files that are modified and untagged. I open a visual interface to view the changes in the files and they are 100% the same. When I run

git diff

I get:

The file will have its original line endings in your working directory. warning: CRLF will be replaced by LF in src/private/library/arialunicid0-chinese->traditional.php.

My question is why are all of these files considered to be modified? Shouldn't my branch be clean, with no changes if I just checked it out?

Upvotes: 1

Views: 402

Answers (1)

Nevik Rehnel
Nevik Rehnel

Reputation: 52055

To quote the git checkout manpage,

git checkout <branch>
Local modifications to the files in the working tree are kept, so that they can be committed to the <branch>.

So no, the working copy will not always be clean after a checkout; your files were probably modified before the checkout, or your autocrlf settings are messing stuff up for you. It's generally less of a headache to turn off EOL-conversion in Git and instead make sure that all developers use editors which can handle all EOLs -- and agreeing on one kind of line ending (e.g. unix-style, LF only).

Upvotes: 2

Related Questions