Catégories
Git Programmation Unity

Smartly git ignore assets from the store

# Add to .gitignore

!Assets/Oculus/
Assets/Oculus/*

# ... read more for full config

In a Unity project, we often use assets from the Asset Store or other sources which sometimes happen to be quite big. For example Oculus Integration uses almost 700 MB. There is no point adding this whole folder to git when you can download it from other source. This is especially important when your git repository has size limits, like with GitHub, Gitlab, Bitbucket, etc.

This post shows a way to ignore such a folder, but still track important files such as configuration or a readme file to track the current version and location to install/update.

Oculus Integration example

Let’s use Oculus Integration as an example. The package can be installed form the Asset Store for the latest version or from https://developer.oculus.com/downloads/package/unity-integration/ for any version. Both end up with the folder Assets/Oculus with a size of almost 700 MB

.gitignore

The following snipped can be added to the .gitignore file to:

  • Ignore the full Oculus folder
  • But don’t ignore it’s configuration
  • But don’t ignore a text file with download informations
# Ignore Oculus folder, but not important files
!Assets/Oculus/
Assets/Oculus/*
!Assets/Oculus/_IMPORT_VERSION.txt
!Assets/Oculus/_IMPORT_VERSION.txt.meta
!Assets/Oculus/OculusProjectConfig.asset
!Assets/Oculus/OculusProjectConfig.asset.meta

Download informations

To let other users know which version has to be installed, we can add a file, which name should not conflict with an existing file. The snipped above mention _IMPORT_VERSION.txt which can for example contain the following text:

Import Oculus Integration

To keep the git repository small, this folder is ignored but you need to import/update it manually from:

https://developer.oculus.com/downloads/package/unity-integration/

Version  44.0 

Drawbacks

While this technique can massively reduce the size of your project’s repository, there is a drawback.

When you decide to update the component to a newer version, even if you take care to update the readme file, there is a risk that nobody else from your team will notice and they will stay with an old version. However this is easy to circumvent. Just communicate directly with them.