79440464

Date: 2025-02-14 19:59:56
Score: 0.5
Natty:
Report link

Git is ignoring empty folders - How do I add an empty directory to a Git repository?

If you would like to not see your empty Test(folder) in the branch where it is empty, you have to delete it in that branch

# Switch branch
git switch empty-folder

# Remove empty folder
rm -r Test

# Check files
tree -a

# Check git status
git status

You will not see any git changes, because it considered Test folder as empty due to the entry in your .gitignore - .DS_Store.


And check the main branch, where folder contains content

# Switch branch
git switch main

# Check files
tree -a

# Check git status
git status
Reasons:
  • Blacklisted phrase (1): How do I
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: Slava