Day 2: Version Control, Pull Commit Push

Tyler Smallwood
5 min readApr 21, 2021

One of the most important things to have while working on a project, whether alone or on a time, is version control. While working on a project and you found a bug that can’t be fixed. What do you do? With version control, you can go back to the last working version. This can save time on projects. Today we’ll go through how to get git and use it with GitHub. To start off we need to download git. Searching git on google will bring you to a git-scm.com page, by searching it’ll figure out what type of system you are using and go to the right download page. So if you are using a Windows machine, it’ll take you to the windows download page. On that page click the download and wait for it to finish downloading.

The download page, in red is the download.

A install wizard will appear. Click next and keep everything as the default setting. Make sure these settings are selected on this page.

These options are needed.

After it is done installing uncheck read notes and check launch git. If you missed it, don’t feat! Go to your start and search git bash and select it when it shows up!

Now that git bash has been opened, maybe you need to go to your correct folder. Using “cd” or change directory will allow you to change the folder that git is in. In the picture below, you can see an example of this being down. If the name of the directory is long, typing just the first few characters and hitting tap will complete it for you. The second line in green has yellow words at the end. That tells you what directory you are currently in.

Changing directories.

Something else that is use for is “ls”. This list everything that is in the current directory.

Everything that’s under the Programming folder

Now to connect Git Bash and GitHub, so we have a place to place our different versions. When you log into GitHub, in the top left corner of the page there is Repositories and New. Click new and this page will show up.

Settings for Repository

On this page, you will need to make sure you are the Owner. The name for your repository. If you would like to, you can give a description but it’s only optional. Next is to decide if you want this to be public, for others to commit, or private, only you can commit. After you have decided is to add a .gitignore, since we will be using Unity, .gitignore will know what files to upload and which ones to ignore. Check the box beside .gitignore and a drop down will appear and just type in “Unity” and select it. Before selecting “Create Repository”, you have an option to change the name of your default branch. Right above the button, there is the option to go to settings to change it. If it’s been decide click the button.

The new Repository.

The next page to come up will the the repository you just created. On this page you will need to click the drop down Code and copy the HTTPS to your clipboard. Now open Git Bash again.Before getting started, make sure you are in the folder you want to commit to the repository. To start connecting it to git hub, type in “git init” this initializes the folder for git. Next will be “git remote add origin {link you copied from github}”. This line tell git bash you want to connect to a remote server and add origin {link}, adds the server named origin. To verify you can type in “git remote -v”.

Now it time to start commit to the repository. But a good habit is to pull from the repository, this allows for you to make sure that everything is up to date for your local file, in case you are working on a team. Use “git pull origin master}”, master is my default branch’s name. After you pull, you can use “git status”, to see what has been committed(Green) and what hasn’t(red) by their color. There is two ways to add files to commit, “git add {name or file/folder to commit}” or the fastest way to add a lot is “git add .”, the dot is a key word for all.

Pulling and adding to be ready for commit.

After everything has been added, next is to commit to the repository. Type in “git commit -m “{Message you would like to add}”, This will commit it and on GitHub, it will post this message. It is good to write what was worked on for this commit. After you commit it, the next step will be to push! This step adds everything to the repository for others to pull on their local machines. To do this type, “git push origin master”.

Committing and pushing.

If at any part of this you get stuck, you can always use git --help and it’ll give some commands to use to get back on the right track! This is how you pull your repository, commit it, and push it back up. This is just the beginning, you can create more branches, so if you have your dev team working on a feature, they can have it all in the dev branch and once it’s ready merge with your master. If something happens, this will allow you to revert back to where you need and more! Happy Learning!

--

--

Tyler Smallwood

I am passonate on learning to program and use Unity to become a skillful Unity Developer