Github Basics - hammerheads5000/Team-Documentation GitHub Wiki
Github is a very useful tool that allows us to share our code, compare different versions of it, branch it off into multiple possible solutions and, easily traverse between its different versions. It is also the website you are using right now! There is much to discuss about the different utilities that github has and the power of git, the base program that github uses, but this page will just cover how to easily share and receive versions of our code.
Setup
To setup Github, first download git, then follow the installation instructions for the method of your choice.
Repositories
A repository in GitHub is basically a fancy file folder. A repository holds all of the files that our code consists of as well as the different versions of that code. To get a copy of the code onto your personal computer you can "clone" it and create an identical copy of the repository in your file system.
Branches
Each repository is broken up into different branches, branches are the different versions of the code that are held by the repository. For example, almost all repositories have a "main" branch which contains the code that is most important or up to date. Another branch might be called "Current Auto" which is the version that has the autonomous code in it. Splitting the code up like this is beneficial because if one branch has a bug in it the other branches can still be tested before resolving the unrelated bug.
Cloning
As said above, you must clone a repository to get the code onto your computer. There are many different ways to do so from using the command line to just downloading a zip file from the GitHub page. The easiest way by far though is to use the GitHub desktop app. Once you have downloaded and logged into Github Desktop, there will be a button in the top right corner that says "Add" clicking this reveals a drop-down with the option "Clone repository". At this point, you will be asked for a URL. This URL will be posted on Google Classroom. For future reference, you can get the URL easily from the online GitHub repository page by clicking the green "Code" button and copying the URL it provides in the drop-down.
Making Changes
Pushing, Pulling, Fetching, and Commiting are the four main operations you will need to do to manage code with GitHub. They are all actually very simple.
Pushing
This Sends your new code out to replace the old code in the repository. This will make a "push request" which one of the captains can then approve which gives people the ability to review the new code before it is accepted.
Fetching
This contacts the online repository and just checks if it has been updated more than your local clone.
Pulling
This copies the code on the repository and updates your clone of the code to match any updates that have been made.
Committing
This just confirms the changes you have made to your code and prepares them to be pushed. It also allows you to title the commit and give it a note. If you would like to be really cool, you can commit after each change/fix you make and give them all descriptions, It makes code much much easier to review.