I am learning git and was was surprised by the fact that staged files created while being in topic branch are not deleted when checking out to the master.
For example:
git checkout -b topic
nano newfile.txt
git add newfile.txt
git checkout master // newfile.txt is still in the working directory, even though it was created in topic branch
I am well aware of git clean
command, it's just that I expected that all files that were never committed are removed if you checkout to a different branch.
Am I missing something here or is this the expected behaviour of git?