Add existing Unity project to GitHub Desktop

Setting Up Your Project with GitHub Desktop

FJ Hagen

Aug 16·3 min read

Having ones computer crash and losing all their work is the worst nightmare scenario for any developer. Luckily, theres a way to prevent losing work in the event of a crash: version control. Version control allows developers to keep track of changes to their projects over time. It also makes it easy to retrieve an existing project and work on it from another computer. As a Unity Developer, I use GitHub Desktop for version control. Now, Ill show you how I set up a Unity project with GitHub Desktop.

First, go to GitHub and create a new repository. Give it whatever name you want and add a description if you like. The important part here is the .gitignore file. Click the Add .gitignore checkbox, and a dropdown will appear. Choose the Unity template. This template tells Git to ignore certain files so each commit wont be thousands of files large.

Now go to GitHub Desktop and click on File > Clone Repository. Navigate to the repo you created, and click Clone.

I already cloned this repo.

Open Unity Hub and click on the blue New button. In the project window, select the 3D template. The important part here is to save it in the same folder where you cloned your repo.

In a couple of minutes, your project will be ready. At first, there will be thousands of changed files listed on GitHub Desktop.

What happened to .gitignore?

Thats because the .gitignore file is not in the right place. If you go to the repo folder, youll notice that the .gitignore file is separate from the Unity project. Move the file to the folder where your Unity project is. Now, there will be far fewer files since .gitignore is now telling Git to ignore all the extra ones.

Lastly, you can now commit your changes. Add a summary to your commit and click Commit to main. Then, click the button that says Push origin. Now, your project is safe and viewable on GitHub. Ill show the process in this gif:

Now you have a project thats hooked up to version control and ready to be worked on. Happy developing!

Video liên quan

Chủ Đề