DEV Community

Play Button Pause Button
Michelle Mannering
Michelle Mannering

Posted on • Updated on

TIL • I discovered GitHub for Unity and GitHub CLI commands

Probably the coolest thing I learned this week, is how to better use GitHub with Unity. One of the problems with Unity is there are a lot of tiny files and some of them have exceptionally long file names.

GitHub for Unity

A quick Google search of the term “how to store Unity files on GitHub” gave me an interesting result: GitHub for Unity. This is an open source project which adds GitHub directly into Unity. It’s almost like working with GitHub desktop, only within Unity itself. You can choose the files you want to add, enter your commit message, and then commit to main all from Unity. But this still didn’t solve the problem of these crazy long file names that don’t seem to fit nicely into GitHub.

GitHub logo github-for-unity / Unity

GitHub for Unity

GitHub for Unity

NOTICE OF DEPRECATION

This project is dead y'all! Remove GitHub for Unity from your project, then go to https://github.com/spoiledcat/git-for-unity and install Git for Unity from the instructions there.

What is it

The GitHub for Unity extension brings Git and GitHub into Unity, integrating source control into your work with friendly and accessible tools and workflows.

You can reach the team right here by opening a new issue. You can also tweet at @GitHubUnity

Build Status

Notices

Please refer to the list of known issues, and make sure you have backups of your work before trying it out.

From version 0.19 onwards, the location of the plugin has moved to Assets/Plugins/GitHub. If you have version 0.18 or lower, you need to delete the Assets/Editor/GitHub folder before you install newer versions. You should exit Unity and delete the folder from Explorer/Finder, as Unity will not unload native…

That’s when one of my viewers (remember I am streaming while I’m learning) chimed in and said I should use the command line. I’ve been doing a lot of work using the GitHub CLI and it’s been amazing. Being able to clone, fork, create repos and more from the terminal makes life a lot easier. I totally forgot (or rather didn’t really know how) the command line allows you to make lots of changes all at once.

GitHub Command Line for uploading long Unity files

You’ve probably heard of .gitignore, which means you specifically identify files for git to ignore; or rather not bother committing them to your repo. If you want all your files in one place then this isn’t really an option.

So what do you do to get all these long file names onto GitHub? Use the command line. Here’s the commands we discovered to help you commit your Unity files to GitHub.

Make sure you have the GitHub CLI installed:
gh

This command will tell you whether the CLI is installed, as well as information about what version you have. Plus it gives you a list of useful commands to get you started.

Next you need to navigate to your local git folder:

cd #add your file location for your local project here

Now we need to change all the long file names:

git config --system core.longpaths true

It will look like nothing happens, but all the names changed. If this doesn't work for you, then run your terminal as admin. Also, make sure you have Unity closed in order to do the above step. Otherwise you'll get permission denied errors.

Then add all the files to your local git:

git add .

The add . means that you're all all the files in your local directory.

git long

Commit all the changes:

git commit

Lots of changes will happen, and colours. Make sure you then finalise the commit by adding the commit message:

git commit -m #add your commit message in here

This might take a while depending on how big the repo is.

At this stage they are still on your local machine. Now you just need to add them to GitHub. Do this by using:

git push

git add

Join me on Stream

I had a lot of fun learning about this and really excited to see some more open source projects as we stream. If you want to join in on these streams, follow me on Twitch and tune in when we go live. Guaranteed fun times, learning, and lots of great networking.
If want to watch these recordings then check out the first and second streams on Unity game dev.

Join the LEGO Game Challenge

We are also using the LEGO Microgame to test this all out and have some fun. Participate in the LEGO Microgame challenge to win cool things.

Top comments (0)