Calfater
Calfater

Reputation: 1315

Why git modification on a branch also modify another

I already read this question: Modified files in a git branch are spilling over into another branch and I understand (I hope) how git works.

Could you explain me why it works like that, I do not understand the mindset. I only found disadvantages but no advantage...

Upvotes: 2

Views: 122

Answers (1)

VonC
VonC

Reputation: 1323593

The idea is to not change a file being modified without the explicit user's authorization: that is the "mindset": no unwanted "surprise".

Changing branch doesn't change by default modified files.
It actually blocks the checkout if those modified files would be overwritten during said checkout: it is up to the user to decide if those changes stay or go.

"In practical": you don't want a tool do do anything "for you". You want to use the tool the way you intent.

If you intent to clean untracked files:

The tool alone cannot decide what should be done with those untracked/modified files when switching branch.

Upvotes: 2

Related Questions