Skip to the content.

Git

Back to Software Docs

Git is a version management tool used by our team to keep track of code changes. Specifically, our repos are hosted on GitHub. On our GitHub, you will find code for various projects and competitions.

What is Git?

What is GitHub?

Repositories

Local vs. Remote Repository

Local Repository:

Remote Repository:

Git

Installation - Command Line

Linux (Debian/Ubuntu): sudo apt install git

Linux (Fedora): sudo dnf install git or sudo yum install git

Mac: https://git-scm.com/download/mac

Windows: https://git-scm.com/download/win

Installation - GUIs

You will still need command line!

Basic Commands

Need help with a git command?

Use git help [COMMAND]

This lists out how to use the command and possible flags to use alongside the command for different functionality.

Example Usage:

Note: git help can also be used as a standalone command or as git help --all to list the most common or all available commands, respectively

Commits

Commits create a snapshot of the current state of your code.

git add <file>

git commit -m “YOUR COMMIT MESSAGE”

How to write commit messages: https://chris.beams.io/posts/git-commit/

Branching

Branches are a set of code changes that can operate without affecting the main codebase.

Essentially, a branch has a separate history from the main codebase.

git branch <branch_name>

git checkout <branch_name>

To create a new branch, use git checkout -b “feature/<branch_name>”

Note: the “feature/” part is there as our naming system for our branches. “feature/” is the most common type of naming convention you will use; it indicates a new feature will be added to the branch. You can also use “bugfix/” to indicate your branch is for smaller updates and fixes to the current code.

Pushing

Pushing updates the remote branch with the current commit on your local branch.

git push or git push origin master

If you’re working on a local checked out branch you’ll have to set your remote counterpart with git push --set-upstream-to origin <branch_name>

Merging

Merging unifies the code of two different branches.

git merge <other_branch>

Note that this will merge other_branch into the branch you’re currently on. Only do this after you’ve committed, pushed, and been approved for your current branch’s code.

Merge Conflicts

Sometimes the changes on two different branches are conflicting. Git doesn’t know how to decide between them, so you must choose manually.

Pulling

This is how you can update your local repo with the latest changes from the remote repo

git pull

Pulling will merge changes from the remote branch into your local branch.

This may happen automatically or could result in merge conflicts.

GitHub

Pull Requests

Pull requests are mainly for merging a remote branch into the master branch.

Leave comments, request reviews, make new commits until it’s ready.

Issues

Issues track problems/to-dos in a repository.

They can be given description, to do actions, and be assigned to specific people.

Projects

Project boards show what tasks need to be done, who is working on which tasks, and what has been completed.

Can be linked to address certain Issues!

More Resources