I have been trying to set-up repository with gitlab CE, as a part of the set-up created a repo and been playing around with it, when I encountered, that after I make some modifi
Git won't change files that are not currently tracked in the repository.
In your example, you only created an untracked file (newfile
).
So the Git's behavior is absolutely normal.
If you git add newfile
without commiting the changes, Git won't allow you to switch to master branch.
For example, this will be handled by Git:
$ git branch new-branch
$ git checkout new-branch
Switched to branch 'new-branch'
$ echo "test" > newfile
$ git add newfile
$ git checkout master
A newfile
Switched to branch 'master'
For in depth explanations: https://stackoverflow.com/a/8526610/882697