I have been exploring git and I noticed that when I checkout different branches in terminal I notice the changes reflected in finder. So, if branchA
has file1 and branchB
has file1 as well as file2 and i run git checkout branchA
, I look in finder I see file1 in my git directory. But if I run git checkout branchB
and look in finder I see file1, file2. Ok, great. It seems git modifies the current directory based on which branch is checked out.
However, I recently cloned a remote repo. Lets say master has file1 in it and that is it. I am in master. I than create newBranch and checkout to it. I run echo "test" > test.txt
. Now when I checkout either branches test.txt shows in finder. But I added text.txt while I was checked out in newBranch, not master.
I feel uneasy about seeing this new text.txt file in the finder directory even when i checkout back to master. Shouldn't it revert to the initial state after cloning. When it only contained file1? And I will see file1 + test.txt when I checkout to the new branch where I actually added it. How can I understand this behavior?