TIL • I discovered GitHub for Unity and GitHub CLI commands
Tags: github, opensource, unity3d, gamedev
Published: 2021-02-12 07:18:21

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](https://unity.github.com/). 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 github-for-unity/unity %}

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](https://cli.github.com/) 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](https://dev-to-uploads.s3.amazonaws.com/i/87sfnzh1yx7eh07eoi2x.gif) 

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](https://dev-to-uploads.s3.amazonaws.com/i/5vdhif6msaf74p3zqpwy.gif) 

## 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](https://twitch.tv/MishManners) 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]( https://www.twitch.tv/videos/910770320) and [second](https://www.twitch.tv/videos/910781876) streams on Unity game dev.

## Join the LEGO Game Challenge

We are also using the [LEGO Microgame](https://store.unity.com/lego-microgame) to test this all out and have some fun. Participate in the [LEGO Microgame challenge]( https://ideas.lego.com/challenges/6811cf30-f944-4dfa-8714-9b38be6fbb52?query=&sort=top) to win cool things.