As I'm working on a project with uncommitted files, there are times when I have to switch to a new branch.
Sometimes Git switches to a new branch just fine, and takes the changes along with me.
$ git checkout development
Switched to branch 'development'
M SomeFile1.py
M SomeFile2.sh
Your branch is up to date with 'origin/development'.
Other times it requires that I either commit or stash my changes when switching to a branch.
$ git checkout development
error: Your local changes to the following files would be overwritten by checkout:
SomeFile1.py
Please commit your changes or stash them before you switch branches.
Aborting
I can't understand the scenario in when it will switch branches automatically while brining the changes along, versus making me commit/stash my changes before switching.
I either stash/commit my changes if I do get that message, but I am trying to understand the scenario in which that happens versus when it will just switch branches automatically and bring the changes with me.