I’ve recently started learning Unity, which has been a ton of fun. I’ve been following some online guides and tutorials, and I started building a small game as a personal project. I’ve been enjoying it a lot, and I decided I was interested in building a game as part of the OSU Senior Capstone project. I found a team who in also interested in game dev, and I’m excited to learn some new skills!
For both my personal projects and our team’s collaborative project, I want to use Git and GitHub, so I’ve been learning how to set up Unity and Git to work well together. Here are some resources I found helpful for adding Git version control to your Unity project.
1. This article by Rick Reilly
I found this to be an incredibly helpful walk-through on how to set up Git with Unity. Rick first explains some common problems faced when using Git with Unity, to identify what problems we’ll need to solve with our setup. The article then lays out 3 solutions to resolve these issues, with easy steps to follow for each one:
- Add Unity-specific .gitignore settings
- Configure Unity for version control
- Use Git Large File Storage
2. This .gitignore template
GitHub provides this super handy .gitignore template specifically for Unity projects. GitHub provides lots of other .gitignore templates as well! Check them out here: https://github.com/github/gitignore
Sort of related note: I often find myself needing to ignore already-tracked files in my Git repos (because thinking ahead is hard). If you ever need to stop tracking and start ignoring a tracked file in your repo (without deleting it from your local files), you can add the file to your .gitignore file and use the command
git rm --cached to stop tracking it.
3. The Git LFS site
The Git Large File Storage site provides installation instructions and downloads to get you set up using Git LFS.
There are 2 basic steps to set up Git LFS:
- Install Git LFS
- Select which file types you’d like Git LFS to manage.
You can track specific file types with Git LFS by adding a .gitattributes file to your repository. Rick Reilly’s post helpfully includes a sample .gitattributes file you can use as a template.
You can alternatively track file types using the command
git lfs track, i.e.
git lfs track "*.psd".
To check the status of your repo’s Git LFS, use the command
git lfs status.
4. The Unity Manual
The Unity Manual provides some (limited) information on setting up external version control systems for your projects. It doesn’t seem to mention Git anywhere, but it does provide steps for configuring Unity to use an external control system.
? __|__ / + + \ \ ::::: / )==||```````||==( \_______/ // || \\ ] ] ]