Reputation: 1935
Let's suppose I am on master branch and then I do :
git branch new_branch
git checkout new_branch
touch newFile.txt
When I do git checkout master to come back to my master branch, I expect I have a clean workspace and no trace of newFile.txt. But git automatically moves newFile.txt in my master branch.
Is this the default git behavior? How could I change it?
Thanks.
Upvotes: 1
Views: 42
Reputation: 265141
Uncommitted changes are not part of any branch, they live in the working copy. To remove untracked files, use the git clean
command. This is default behavior of Git and cannot be changed.
Also, see Move existing, uncommited work to a new branch in Git. Whether or not the branch is new or an existing does not really matter.
Upvotes: 3