Eugen
Eugen

Reputation: 2990

unexpected changes after checkout

I have a remote GIT repository, which I clone locally.

After that I change the branch to another one, do nothing, then try to change to another branch, and GIT is saying there are uncommitted changes!?!

How in the world there are changes if I didn't do anything just changed branches.

See this action in the console.

enter image description here

I did set

git config --system core.autocrlf false

but it didn't help.

What's happening here, never saw such a behavior. The guy who committed to perftech branch works under Windows as me.

thx

Upvotes: 3

Views: 1241

Answers (1)

CodeWizard
CodeWizard

Reputation: 142094

Update:
After long chat - we found the problem: There are multiple contributors to this project and one of them has set a different CRLF value then the others which cause the problem.

Solution:
Make sure all the team is using the same CRLf configuration to avoid those problems.


How to see what has been changes?

First of all see what has changed and then try to understand out of it how come the files are modified.

git log HEAD^..HEAD

# to view the diff by words instead of lines:
git diff --color-words!

Once you see the changes try to figure out where did they came from.

Also verify that you don't track filemode in case the chmod was updated on those files


Git has something known as 3 states

enter image description here

The 3 states are your

  • Working directory
  • Index/ stage area
  • Repository

The important part of this structure (relevant to your question) is this:

The working directory && staging area are shared not modified once you checkout branches

Which means that if you switch branches they will remain in the previous state with all the changes you have made to them.

The only thing that is changes is your HEAD.
To understand what is HEAD read this out, it will explain in detaisl what is HEAD in git:

How to move HEAD back to a previous location? (Detached head)

Upvotes: 1

Related Questions