How to Set Up Unity with GitHub


Hey folks, welcome back to Vector Z! I’m Akash. In our previous video, we created a Unity project. In this video, we’ll be setting it up with GitHub. Let’s get started!

Why Use GitHub with Unity?

  1. Version Control: Track all changes made to your project. If something goes wrong, you can revert to a previous version.
  2. Collaboration: Easily collaborate with other team members.
  3. Backup and Restore: Your project is safely stored on the cloud. If something happens to your local files, you can restore them from GitHub.
  4. Branching: Work on separate branches for different features or bug fixes without affecting the main project.

Step 1: Initialize Git in Your Project

  1. Open your project folder.
  2. Right-click and select “Open in Terminal.”
  3. Type git init and press Enter. This initializes Git in your project folder.
  4. To confirm, go to “View” > “Show hidden files” and check for the .git folder.

Step 2: Create a GitHub Repository

  1. Go to GitHub and log in. If you don’t have an account, create one.
  2. Click on “New” to create a new repository.
  3. Name your repository (e.g., GetawayBlitz).
  4. Add a description (e.g., “This is the official repo for Getaway Blitz”).
  5. Set the repository to private.
  6. Add a README file.
  7. From the .gitignore dropdown, select “Unity” to exclude unnecessary files from your repository.
  8. Click “Create repository.”

Step 3: Generate a Personal Access Token

  1. Go to your GitHub profile > Settings > Developer settings.
  2. Click on “Personal access tokens” and then “Tokens (classic).”
  3. Generate a new token with the necessary permissions.

Step 4: Install and Set Up SourceTree

  1. Download and install SourceTree, a GUI application for Git.
  2. Open SourceTree and click “Add.”
  3. Browse to your project directory, select the folder, and click “Add.”
  4. Click “New tab” > “Remote” > “Add account” to add your GitHub account.

Step 5: Connect SourceTree to GitHub

  1. Copy the repository link from GitHub (HTTPS link).
  2. In SourceTree, go to “Repository settings” > “Add” under “Default remote.”
  3. Paste the link, but modify it to include your username and personal access token:
   username:TOKEN@github.com/username/repository.git
  1. Click “OK” to save the remote connection.

Step 6: Pull and Push Changes

  1. Click “Fetch” to fetch remote branches.
  2. Ensure the main branch is selected.
  3. Click “Pull” to pull changes from GitHub.
  4. Go to your project directory to verify the .gitignore and README.md files.
  5. In SourceTree, stage all changes, write a commit message, and click “Commit.”
  6. Click “Push” to push changes to the main branch on GitHub.

Conclusion

That’s it! You’ve successfully set up your Unity project with GitHub. In the next video, we’ll be making changes to the URP settings to enhance our project’s visuals. If you found this video helpful, please like, subscribe, and share. Stay tuned for more tutorials!


Thank you for reading! If you have any questions or need further assistance, feel free to leave a comment below. Happy coding!

Leave a Reply

Your email address will not be published. Required fields are marked *