1

Suppose I have a repository with branches A and B, stemming from the same origin. I switch to the A branch and delete some directories. Those directories contain some files. Then I do commit and switch to the branch B, where those directories are not deleted yet. So, I merge B with A but I don't see folders being removed in branch B. Rather I have weird situations with half-deleted folders and self-restoring folders. So, how do I correctly commit and merge deletions into the main development branch?

GuardianX
  • 512
  • 9
  • 27
  • Can you be a little bit more specific about what you mean here *Then I do commit and pull another branch B*? – Tim Apr 01 '15 at 14:05
  • @TimCastelijns well, basically I just switch to the branch B. I edited the question to clarify. – GuardianX Apr 01 '15 at 14:07
  • 3
    Git doesn't track directories. For example, Git only cares about a directory `foo` if it is necessary for a tracked file such as `foo/bar.txt`. – chepner Apr 01 '15 at 14:07
  • possible duplicate of [How to remove a directory in my GitHub repository?](http://stackoverflow.com/questions/6313126/how-to-remove-a-directory-in-my-github-repository) – René Höhle Apr 01 '15 at 14:08
  • 1
    @chepner Or if it contains a `.gitkeep` file (not actually a Git feature, just a convention thing if you wanted to track folders). – sjagr Apr 01 '15 at 14:12
  • well, those folders are not empty, of course. But when I do commit and switch back to the A branch, the folders and their nested folders are restored. The files are gone, but directories are there. – GuardianX Apr 01 '15 at 14:15
  • 3
    Git is treating the directories like any other untracked file; it doesn't delete them when changing branches. – chepner Apr 01 '15 at 14:18

0 Answers0