How to start a new Unity project with git
Several people ask me how to start a new Unity project with git, so I decided to make a post to help all those people (and some new ones).
Here is what you need:
- a Bitbucket account (or any other git server provider you prefer) properly configured with your computer ssh key
- SourceTree, the best GUI for git and mercurial in my opinion, intalled and configured
- a .gitignore file to make sure you are commiting only the files needed
- Unity engine installed
These are the tools that I’m using, but the instructions could help you with others too.
Before you start, make sure that SourceTree and Unity are installed and working properly.
With that, you can start your new project in Unity following these instructions:
- Create a new project in Unity inside an empty folder.
- Follow the instructions that are in this post to create a .gitignore and configure Unity to accept the version control system.
- Create a project in Bitbucket using the button Create in the top bar. Fill the project informations and click on “Create Repository”.
- In the new screen that appeared, click on Clone button and you will see a command line selected. Copy it.
Note: If you are using SourceTree, you can click on Clone in SourceTree button instead and jump to step 7.
- Now, inside SourceTree, click on Clone/New and a “Clone/Add/Create Repository” window will show up.
- Inside the Source Path/URL text field paste only the address part (starting with
firstname.lastname@example.org) of what you copied in step 2.
- In Destination Path, insert the location where you just created the Unity project and click in Clone.
- And you are ready to make your first commit! Just remember that git, like several other versioning systems does not commit empty folders by default. So you can add some code before your first commit.
I hope this was helpful.