Training Missions

Missions: Using Git

Quick reference

Tools for working with git

If you already have git installed, you may type "git" in the terminal to bring up a list of commonly used git commands, or type "man git" for the full manual. If you don't have git installed yet, please check out this tutorial on how to set it up on your system.

This page is just a quick reference of the git tools that we have learned; see the bottom for other resources.

Configuring git

To configure your name:

git config --global 'First Last'

To configure your email:

git config --global ''

Cloning a git repository

git clone [url] [folder]

[folder] is optional. It's for if you want to clone the respository into a specific folder in the current directory. If the folder name specified does not already exist, it will be created.

Creating a patch

To check the status of the repository:

git status

It's highly recommended for you to check the status of the repository before performing any git commands, so you can avoid unnecessary problems such as commit collisions.

To prepare the modified files for committing:

git add [file]

Note that you may add more than one file by simply concatenate more [file] at the end, seperated by a space.

To record the changes as a commit:

git commit -m "message"

To create a file containing the patch:

git format-patch origin/master

Rebase and merge

To update the local copy of a repository:

git fetch
git rebase origin/master

Other resources

There are many git tools and options. While the ones we mentioned here are commonly used ones, there are many other useful ones you should know. For further reading: