Search code examples
gitmergebranchworkspacegit-checkout

Should Git workspace automatically adjust to the content of a specific branch?


Git checkout/pull doesn’t remove directories?

I'm kind of new to git and slowly learning various parts of it.

So forinstance I have a branch

Master with FolderA

I have later from Master created a branch

Dev and added FolderB

So Dev as result have FolderA and FolderB

now when I do git branch master, I'm assuming folder B should be deleted.

But I see FolderB as unstaged folder in master, as I understand it should be removed.

Further more, if I go ahead, when in branch Dev deleting FolderA, when changing branch

to master and back to Dev FolderA appears unstaged in branch Dev.

So why is git not deleting these folders? should I always do some sort of clean command like git clean -f -d?

Or what am I missing?

My real scenario is much more complicated however this simple example should cover the problem I'm experiencing at a larger scale.

Just to be clear: This questions is about content of the branch, it is not concerned with folders only. However the answer is similar to another question pointed out here, but the questions is different.


Solution

  • Although Git manages the files within your folders, it doesn't delete the folder itself when switching to a branch where the folder isn't needed. Don't worry about it, you're not missing anything.