Introduction to Git

Jose Robledo

04 March 2025

Course content

01. Intro to Git

02. Setting up Git

03. Creating a repository

04. Tracking changes

05. Exploring History

06. Ignoring things

07. Remotes in GitHub

08. Collaborating

09. Branching and Merging

Goals for this course:

  • Get started with Git! Improve your daily workflow
  • Understand the benefits of an automated version control system
  • Understand how Git works and gain awareness of its most useful features
  • Host local git repositories on the cloud using Github

Schedule

Day 2

09:00 Git: creating repo and tracking changes
10:30 Morning break
11:00 Git: History and ignoring things
12:00 Remotes in GitHub
12:40 Post-workshop Survey
13:00 END

Do you have Git?

We will be using Git interactively today, so it’s important that everyone has it installed locally! Most probabily you already have it installed, if not, you can find how to install it here

We can check if we have Git by opening a command-line/terminal and typing in:

$ git
  • Reminder: Don’t write the $ sign! This is just an indicator that the following prompt should be typed in your terminal.

$ git
usage: git [-v | --version] [-h | --help] [-C <path>] [-c <name>=<value>]
           [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]
           [-p | --paginate | -P | --no-pager] [--no-replace-objects] [--bare]
           [--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]
           [--super-prefix=<path>] [--config-env=<name>=<envvar>]
           <command> [<args>]

These are common Git commands used in various situations:

start a working area (see also: git help tutorial)
   clone     Clone a repository into a new directory
   init      Create an empty Git repository or reinitialize an existing one

work on the current change (see also: git help everyday)
   add       Add file contents to the index
   mv        Move or rename a file, a directory, or a symlink
   restore   Restore working tree files
   rm        Remove files from the working tree and from the index

Github?

We will also be needing to use Github if you want to follow up on the tutorial on how to push your local repository to the cloud. There are other options (Gitlab, Gitbucket, etc.) but we provide a tutorial for Github.

Instructions to create a Github account

Prepare Working Directory

$ cd
$ cd Desktop 

What is Git?

Automated version control system

  • Single user

  • Two users

  • Modify the same thing? ➡️ conflict

Version control

  • A version control system is a tool that keeps track of these changes for us, effectively creating different versions of our files.

  • It allows us to decide which changes will be made to the next version (each record of these changes is called a commit), and keeps useful metadata about them.

  • The complete history of commits for a particular project and their metadata make up a repository.

  • version control is like unlimited ‘undo’ or CTRL-Z.

  • Allows many people to work in parallel.

Continue with

02. Setting up Git

Content

01. Intro to Git

02. Setting up Git

03. Creating a repository

04. Tracking changes

05. Exploring History

06. Ignoring things

07. Remotes in GitHub

08. Collaborating

09. Branching and Merging