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 on fcs-cs2613-dev is nano; most other places it is vim. 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, but note this probably won't work in an FCS VM.

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