I have two branches: master and web and I have my working copy in one directory. In web branch I've the folder foo. I worked on foo's files and I committed the job. Then I switched to master with:
git checkout master
But foo folder is still there in my working copy. It looks strange! Git status on master branch tells me the all is fine. But the folder foo does not belong to master branch. Even If I do
git checkout .
web folder stays in my working copy. To fix I rm web folder. Now, git status keeps telling me the everything is fine and so it is.
But it's very strange, what could have happened and how can I avoid that?
I think you have a file in foo that is commited to master as well. Compare the output of
git checkout web
git ls-files foo
with
git checkout master
git ls-files foo
The ls-files command should return empty if the folder is not versioned. But I think you will get output anyway.
Git does keep track of which folders are exclusive to a branch and will remove them when switching branches. git status also reports on all untracked files that are not in the .gitignore.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With