Unity project's .gitignore is ignoring meta files

3.8k views Asked by At

So I'm pretty familiar with git, but have always had a repo master that has created a .gitignore file for me, so this is my first time dealing with it by myself. My problem is that when I commit my Unity project, and pull it from a different computer, the metafiles have been ignored (I suspect), and all of the GameObjects in my scene get deleted. Here is the tutorial I followed with the gitignore file I am using.

2

There are 2 answers

0
FastFwd On

GitHub provide a comprehensive .gitignore file for Unity projects that you can choose when setting up your repository.

It is also available here if you are using a different provider.

3
Get Off My Lawn On

I have seen lots of people make these huge .gitignore files, when really all they need to do is this:

# Ignore Everything
/*

# Except for these:
!/.gitignore
!/Assets
!/ProjectSettings

What this is doing, is:

  1. Ignore everything
  2. Then it un-ignores the rest
    1. The .gitignore file
    2. The Assets folder
    3. The ProjectSettings folder

This should the not ignore your meta files, or anything in the Assets folder for that matter.