TUTORIAL: Tell Me How To Git - radiatoryang/fall2018_gamedev1_morning GitHub Wiki
- it's OK if it's a brand new Unity project
- make sure you know the folder's location on your hard drive
- go to https://www.sublimemerge.com/ and download and install it for free
- DO NOT google it and go to "Sublimerge"... it's called SUBLIME MERGE. Two words.
- You may have used SourceTree or GitKraken in the past. GitKraken has locked an important function behind a paywall, and SourceTree is... well, let's just try something new.
A Git repository ("repo") is a folder that remembers how it changes
- in Sublime Merge, click
New Repository
and browse to your project folder (the folder that has \Assets\ and \ProjectSettings\ in it) - (VERY IMPORTANT) then go to
Tools > Edit .gitignore...
and open it in a text editor like Notepad (Windows) or TextEdit (Mac)- google "gitignore unity", click the first result, then copy and paste that template into your own
- WHY? the GitIgnore tells Git what files to ignore, and for Unity, we want to ignore 99% of these files... if you don't do this step, then you will have to check thousands of useless files every time you use Git
double-check: if Sublime Merge still says something like "Untracked files: 1000", then you did not do step 2 correctly
Git is only useful if you make commits -- a commit is a snapshot / backup of all the files in your folder
- click on
Commit Message
and type a good message to describe your changes- good example: "initial commit" or "added new script for level 3, changed rock model to look more orange"
- bad example: "blah" or "robert smells" or "I hate git"
- to commit a file, you must "stage" it first
- click
Untracked files
button - click the
Stage
button next to each file you want to stage (hint: all of them) - if it takes too long: click on the long "master" button at the top (to open the Command Palette), type "stage all", and press ENTER
- click
- click
Commit __ files
button
double-check: you should now see your new commit in the timeline in the left sidebar... if you don't, repeat step 3
So far, we have done this only on your own "local" computer. We need to create your repo's twin on GitHub, the "remote" repo
- go to GitHub.com, log-in, click the
+
button in upper-right corner, and selectNew Repository
- name your GitHub repository
- ignore GitHub.com's bad name suggestion
- type in a good descriptive name, like "gamedev_midterm", or whatever your game concept is
- (optional) type in a description too
- Click the green
Create repository
button! DO NOT CLICK OR EDIT ANYTHING ELSE- DO NOT "INITIALIZE THIS REPOSITORY WITH A README"
- DO NOT ADD A GITIGNORE (we already did that in step 2)
- DO NOT ADD A LICENSE (you can do that later if you want)
- Now on your empty GitHub repo page, copy the URL underneath "Quick setup"...
- it should start with "https"
- it should end with ".git"
We need to tell your "local" repo about the "remote" repo on GitHub
- in Sublime Merge, click the
Up arrow
in the upper-right- type in "origin" and press enter
- paste the URL from that GitHub page (from the end of step 4)... (it should start with "https" and end with ".git")... then press enter
To upload your files to GitHub, you need to "push" your commits
- click the
Up arrow
in the upper-right to push all commits to GitHub - if it asks you to login with your password, then do that
- work on your game as usual
- every now and then, you should commit and push to save your progress
- you already setup everything, so now you just need to repeat step 3 and 6
Git is only useful if you make commits -- a commit is a snapshot / backup of all the files in your folder
- click on
Commit Message
and type a good message to describe your changes- good example: "initial commit" or "added new script for level 3, changed rock model to look more orange"
- bad example: "blah" or "robert smells" or "I hate git"
- to commit a file, you must "stage" it first
- click
Untracked files
button - click the
Stage
button next to each file you want to stage (hint: all of them) - if it takes too long: click on the long "master" button at the top (to open the Command Palette), type "stage all", and press ENTER
- click
- click
Commit __ files
button
To upload your files to GitHub, you need to "push" your commits
- click the
Up arrow
in the upper-right to push all commits to GitHub - if it asks you to login with your password, then do that