Git and empty folders

Hi,

We’re using git for our version control and we’ve noticed that when switching between branches Unity will remove some empty folders and reports that ‘the asset does not exist.’ The folders *.meta files are tracked in git. We have a few empty folder hierarchies that need to stick around and having to replace them whenever I switch branches is driving me bonkers! Has anyone else had experience with this?

Thanks!

Yup. It’s a git thing, and can be annoying when branching. Git ignores empty folders, but will track the unity meta. The best solution we found for this is to just have an empty txt file in the empty folders you want to retain.

This is a major pain! Back in the days, Unity re-created empty folders that had an existing meta file, which resulted in situations where getting rid of an empty folder that had snuck itself into the project meant that every developer had to delete it at the same time.

@zombiegorilla 's advice is the best - stick an empty file in there. Also check out this post on StackOverflow - you can add hooks that creates the directories if they don’t exist.

Awesome, thanks. I’ve gone with the txt files and it does the job fine. Glad it wasn’t just me!