Back to Basics: Github
Source control
My project is prone to run into errors and may crash while working. In some instances, I may lose my work from crashes or unexpected file corruption.
A solution to be able to keep multiple iterations of my work is keeping it in a repository such as Github. What we refer to as Source Control.
Creating a New Repository
A Repository is a place where we can both store our project files, distribute files, and allows multiple users to simultaneously make changes to the same project files.
log into https://github.com/ , find the green,’New’ button on the top left of the page next to the word ,’Repository’, and clicking it.
A new page will pop up with fields to populate. Fields referring to the repository’s name, permissions, file exclusion, and licensing.
my repository’s name will be
VersionControlBasics
setting it to public
adding untiy to .gitignore so we dont have a load of unnecessary files being sent back and forth.
Ill ignore the licensing section since this is just an example.
Once done, I hit the,’Create Repository” Button.

GitBash
Gitbash is another way to interact with your repository. This is a point of contact where one can execute commands to download any changes or send changes to the repository
repositories may be modified through github’s GUI desktop application or other various third party software. In this instance, I’ll be using gitbash
Start by downloading gitbash here http://git-scm.com/download/win
Gitbash Init
create a new project and save it in a place where I can find it.

Locate my project and right click and click,’GitBash Here’, within its folder. A gitbash window will then display on screen.
Note: Leave all quotation marks and brackets out unless specified.
In the gitbash window, ill type ‘git init’. To initialize the project within our new repository.
Alternatively, I can locate my project using commands such as cp ‘name of directory’ and ls within gitbash.

I go to github, copy the url of the main page of my repository to link up my project. I’ll type in {git remote add origin URL}
I can verify that it went through by typing {git remote -v}

Master To Main (new)
Recently, the IT community has moved away from naming the default branch,’ Master’. The community has decided to rename it to Main due to it being an offensive reference. If our project’s default branch is still named master. Use this line in gitbash to change it
git branch -m master main
I can also change the default naming in git via gitbash using this line
git config — global init.defaultBranch main
Pushing my work into the repository
“Pushing” is simply sending any changes you have made to the repository.
Step 1, Pull:
type in [git pull origin main]

Step 2, Stage:
type in {git status} to insure that they’re contents to stage.
following, {git add .} make sure to add the period aswell.

Step 3, Commit:
Leave quotation mark
{git commit -m ‘whatever comment you like to add here’}

Step 4, Push:
{git push origin main}

It should appear in my github and is ready to be built off of.

Branching
Branching is the act is creating,’branches’ in your repository. It allows individual users to work on a seperate versions of your project and make changes without conflicting with others.
Its important to branch often and branch early as possible when working in a team. Branching is useful to be able to work side by side while having your own place to push your changes. Changes can be stored at ones convivence to later be merged altogether seamlessly.
additionally it can be used to separate a developer build of a product from what the public will have.
list of commands
git branch (this lists branch)
git branch ,’Name’-(this creates a branch)
git checkout ‘Name of branch’ (this switches between branches)
Whatever I push will be stored on whatever branch that is currently selected.
Merging
When a branch is ready to merge into the main version of the project, we do what we call ,’ merge’.
To merge two branches together select a branch using the git checkout command. Then type in
git merge ‘Branch name’.
Reverting a commit
from time to time, mistakes will be pushed into the repository. We can locate the commit by finding its hash code and view it like a branch.
To view all comits we can use the command,’ git log ‘.

we can take a peak at that commit by switching to it by using the git checkout command.
Ex. git checkout 3592a1242d3916e16966f87b881e0ed4db8d591f
once selected, I can open unity and view the contents of the project in that commit.
Additionally I can create a branch from a commit and build off it it by using:
git checkout -b’name’ ‘hashcode’
Resetting a branch
If all else fails. we can completely reset the repository back to a specific commit. Note that in doing this, any branches created after the specified commit will be wiped.
the command is:
git reset — hard ‘hashcode’
Following that, the server needs to be updated.
git push — force origin main