-
Notifications
You must be signed in to change notification settings - Fork 0
Git and GitHub
Git is a very commonly used version control system that is both free and open source. A detailed description of Git can be found here.
All software you use is version controlled. Any time you go to update a program like a game or app, you are changing the version of that software. However, any time a team goes to change something about a program, most likely, they will break something (or everything). It takes time to make sure that the whole program works with the new feature. Version control helps guarantee that users can download and install a useful program while the team is working on new things.
A repository is a centralized storage location for a code project. A repository could be stored on a specific local server that your team manages, or it can be stored externally using some cloud service (we'll get to this later). A repository not only contains all of your code and relevant files, but it also stores each file's revision history and the history of the project as a whole.
Branching is the process of creating a copy of code so that you can work on that copy without messing up the working version. The working copy is referred to as the "main branch." Branching off of the main branch is the most common, but it is also possible to create branches from other branches. Branches should be named something descriptive, such as the feature intended to be added. A detailed description of branches can be found here.
Staging is the process of preparing changes to an active branch. This involves declaring certain files to be included or removed from a repository. This step is often handled automatically by programs built on top of Git.
Commits are often described as "snapshots" of code. A commit step requires some text that describes the changes made or current state of the current code.
After making a commit of the code that you are working on, the next step is to "push" it to the repository. After pushing a commit, every other team member will see those changes on the branch that it was pushed to.
A "pull" will update your local filesystem by downloading the most recent version of the active branch from the repository. If another team member pushes a commit, you will need to pull it.
After a new feature is finished in a non-main branch, it can be "merged" to the main branch. This updates the main branch with the new code developed in the other branch, and removes that branch. This results in a new active version of the project and users will need to update to this new version.
It is important to review a branch, as a team, before merging. Git based programs have a step called "merge request" or "pull request" which prompts the team to review this branch before merging it to the main branch.
Simple projects will go through a simple workflow of branching from main, finishing a feature, and merging to main, and repeating. In this case, there are only ever one or two branches (main or main and development branch). However, team projects will often necessitate multiple development branches being active at any given time. In these cases, it can be useful to use a visualization tool to help understand the organization of the repository, like this. Here is a video tutorial on how to use this tool.
GitHub is Microsoft owned, cloud-based Git system which makes using Git incredibly easy and intuitive. GitHub is completely free, but as a CU student, you have access to GitHub Pro. Follow this link and click "Sign up for Student Developer Pack," select "Student," and then scroll to the bottom where it says "Application." Type in "CU Boulder" and a selection menu will pop up: select "University of Colorado, Boulder (https://www.colorado.edu) (CU Boulder)." Follow the rest of the directions to complete the application. It can take time to process the application, so be patient. As an added bonus, this will also allow you access to Microsoft's GitHub Copilot (a large language model chatbot designed to help you code). Note: large language models utilize an INCREDIBLE amount of energy and water, so please try to be a responsible user, and use it sparingly. Here is another article with discussion on responsible use of large language models.
GitHub Desktop is a program that you can install on Windows or Mac operating systems. It can be downloaded here. The installation is intuitive to follow.
Linux users typically just install Git with
sudo apt install git-all
and control everything from the command line: I expect this to be within reach for any experienced Linux user. The Git program can still interface with GitHub repositories, but it requires managing "tokens." Here is how to set up Git to communicate with GitHub repositories.
A new repository can be created either in a browser, by logging into your account at github.com, or in the desktop app. Instructions can be found here.
Instructions for adding team members to a repository can be found here.
Cloning is the process of downloading a repository to your local computer. This can easily be managed from the GitHub Desktop app. Instructions can be found here.