Version Control with Git

A Better Backup / Setting Up Git

Learning Objectives

  • Explain which initialization and configuration steps are required once per machine, and which are required once per repository.

Prerequisites

In this lesson we use Git from the Bash Shell. Some previous experience with the shell is expected, but isn’t mandatory.

Get Started - The Scenario - Comedy Monsters

Lets walk through a little scenario to get some hands on experience using Git.

Linux and Mac users should open a terminal, windows users to should go to the Start Menu open GitBash from the Git group.

Post-Its

Wolfman and Dracula have been hired by Universal Missions to investigate if it is possible to send their next planetary lander to Mars.

(FULL SCREEN SLIDE 9 /10 - Monsters to Mars)

Switch out of fullscreen Open Terminal

( SLIDE 11 - local configuration)

We’ll start by exploring how version control can be used to keep track of what one person did and when.

Setting Up

The first time we use Git on a new machine, we need to configure a few things.

Make sure you’re in your home directory (not another repository).

$ cd

Set some global options

$ git config --global user.name "Vlad Dracula"
$ git config --global user.email "vlad@tran.sylvan.ia"

(Please use your own name and email address instead of Dracula’s.)

He also has to set his favorite text editor, following this table:

Editor Configuration command
nano $ git config --global core.editor "nano -w"
Notepad++ (Win) $ git config --global core.editor "'c:/program files (x86)/Notepad++/notepad++.exe' -multiInst -notabbar -nosession -noPlugin"

(See the Etherpad)

Git commands are written git verb, where verb is what we actually want it to do. In this case, we’re telling Git:

  • our name and email address,
  • what our favorite text editor is, and
  • that we want to use these settings globally (i.e., for every project),

The three commands above only need to be run once: the flag --global tells Git to use the settings for every project on this machine.

You can check your settings at any time:

$ git config --list

Next - Creating a Repository