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.
2 Solutions collect form web for “Should Git workspace automatically adjust to the content of a specific branch?”
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.
Note: the ability for Git to remove only empty directories goes back to the very beginning of git:
See commit “Remove empty directories after
read-tree -u“, from… Oct. 10th, 2005! (seven years ago)
This fixes everybody’s favorite gripe that switching branch with ‘
git checkout‘ leaves empty directories.
Signed-off-by: Junio C Hamano