Connect Unity projects with Github

While I uploaded Unity project files, I faced a error.
this is larger than GitHub's recommended maximum file size of 50.00 MB

The solution for this error is using Git Large File Storage, in short, Git LFS.
In this post, I will share two ways to connect Unity projects with Github; Git and Sourcetree.

Before starting, (1) download Git LFS and (2) create a new repository with Unity .gitignore.

git_ignore.png

1. Git

(For Mac, Linux) Open terminal and move to your project folder.
(For Windows) Open Git Bash at your project folder.

Then, use the following commands on your environment.
Replace <Github URL>, <file type>, and <folder name> with your own options.

$ git init
$ git remote add origin <Github URL>
$ git pull origin master
$ git lfs install

$ git lfs track "*.<file type>"
$ git lfs track "<folder name>/**"

$ git add .gitattributes

$ git commit -m "Add gitattributes"
$ git push -u origin master

Using git lfs track, choose large files or the whole folder.
I use only git lfs track "Assets/**" for my project.

$ git add .
$ git commit -m "Add all the files"
$ git push

Then you can see files on Github.

2. Sourcetree

Connect a empty local repository with your Github repository.
Go to top bar; Repository → Git LFS → Initialise Repository.
Add using file type or folder name/**.

Then, you just commit the changes and check files on Github.


💬 Any comments and suggestions will be appreciated.

Leave a comment