Search code examples
gitunity-game-enginegitignore

How to ignore one file in gitignore while unignoring its parent folder


I want to ignore everything in my project except for

  1. .gitignore file
  2. Assets folder
  3. ProjectSettings folder

Additionally I want to ignore one file ProjectSettings/ProjectSettings.asset


I searched around and wrote this in my gitignore file:

# Ignore Everything
/*

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

# Ignore just ProjectSettings
!/ProjectSettings/*
/ProjectSettings/ProjectSettings.asset

The problem is it is still including ProjectSettings/ProjectSettings.asset in my commits. How can I ignore this file while un-ignoring its parent folder?


Solution

  • Try Removing the file from git chached:

    $ git rm --cached ProjectSettings/ProjectSettings.asset