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.

  • Overwrite the master branch with a orphan branch in git
  • Separate Git Deployments on a Single Server
  • Deleting git branch loses audit
  • When should you branch?
  • Keep settings in branch
  • Development and testing branch in @nvie's Git branching model?
  • 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.

  • git p4 submit from a bare repository?
  • Which is better for my Git project, submodules or subtree
  • git successfully push changes to main repository but still see no changes in the files
  • git error- did not match any file(s) known to git?
  • `git log -p path/to/file` doesn't show all the changes
  • Delete some commits from remote repository assuming I'm the only person working on it
  • 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 <>

    Git Baby is a git and github fan, let's start git clone.