I am working on a git repository with a master branch and another topic branch. I have switched to topic branch and modified a file. Now, if I switched to master branch that
This is the default behaviour of git.
You can use -f flag to checkout to do "clean checkout" if you like.