Git branch switching does not modify code folder files

This is a question.

I cloned the remote main project folder using the git clone git@git.mytest.com :TEST command. from the root of Git, I made the cd Test to move to this folder. Then I created the branch using git checkout -b myBranch . Now on Git bash it shows that I'm in a new branch. I created the test.txt file in the Test folder, and then switched my branch to master. I still see the text file. Shouldn't Git show test.txt since it is not part of the wizard. Do I need to make changes to the branch if this happens.

I thought that this could happen initially, because it is not part of my .net project (which I have in master and branch). But the same thing happened when I tried to add the file to mybranch. When I switch my wizard, I still see the changed icon for the folders in the system.

What am I missing? Thank you for your help as I spent a lot of time figuring out Git now. Every time I think I have it, there is always something.

+7
source share
1 answer

No, it is not part of your master branch, but it is not part of myBranch . It is not tracked because you never made a file. By running git status , you will see that it is listed as unrestored. Since it has never been delivered or fixed, Git cannot (and cannot) control its existence, so it remains there independently.

In addition, modified files remain between branches if they can. Else Git will give you an error when switching branches around a dirty working tree. This is again, because Git does not have an internal copy of these changes, they exist only in your file system, and not within Git, until they are committed.

+14
source

All Articles