UNB/ CS/ David Bremner/ teaching/ Git basics

Documentation

First, note that you can get documentation for a command such as git log --graph with:

$ man git log

or:

$ git help log

With the latter, you can use the manual viewer of your choice; see git-help(1) for more information.

The man pages are also available online version

A good reference for git (other than the man pages) is The Pro Git Book.

Initial configuration

It is a good idea to introduce yourself to Git with your name and email address before doing any operation. The easiest way to do so is:

$ git config user.name "Your Name Comes Here"
$ git config user.email you@yourdomain.example.com

You may also want to configure an editor to use with git. The default in FCS labs is vim. Some other places it is nano; Both are very fast to start up, but completely keyboard driven. If that doesn't suit you, you can configure the editor via

$ git config core.editor  $something

On the options for $something include

You can optionally used git config --global to set for all repositories in FCS labs.

Common Tasks

For a more detailed introduction, see gittutorial

Committing

To save your changes in the git database,

$ git add file

$ git commit file

Pushing

First make sure the remote origin is set up according to coursegit

$ git push origin main