Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Git and empty folders

Discussion in 'Editor & General Support' started by spraycanmansam, Nov 15, 2016.

  1. spraycanmansam

    spraycanmansam

    Joined:
    Nov 22, 2012
    Posts:
    254
    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!
     
  2. zombiegorilla

    zombiegorilla

    Moderator

    Joined:
    May 8, 2012
    Posts:
    9,042
    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.
     
  3. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    6,294
    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.
     
  4. spraycanmansam

    spraycanmansam

    Joined:
    Nov 22, 2012
    Posts:
    254
    Awesome, thanks. I've gone with the txt files and it does the job fine. Glad it wasn't just me!