+ - 0:00:00
Notes for current slide
Notes for next slide

Git Workshop

Janus Valberg-Madsen

2018-10-22 @ Aalborg University

1 / 32

Overview of today

2 / 32

Overview of today

  1. What is version control, and why should I care?
2 / 32

Overview of today

  1. What is version control, and why should I care?

  2. Overview of the most important Git functions

2 / 32

Overview of today

  1. What is version control, and why should I care?

  2. Overview of the most important Git functions

  3. Overview of GitHub

2 / 32

Overview of today

  1. What is version control, and why should I care?

  2. Overview of the most important Git functions

  3. Overview of GitHub

  4. Live demo showcasing the concepts

2 / 32

Overview of today

  1. What is version control, and why should I care?

  2. Overview of the most important Git functions

  3. Overview of GitHub

  4. Live demo showcasing the concepts

  5. (interactive) Install Git and a client

2 / 32

Overview of today

  1. What is version control, and why should I care?

  2. Overview of the most important Git functions

  3. Overview of GitHub

  4. Live demo showcasing the concepts

  5. (interactive) Install Git and a client

  6. (interactive) Set up a repository on GitHub for your P1 project

2 / 32

Overview of today

  1. What is version control, and why should I care?

  2. Overview of the most important Git functions

  3. Overview of GitHub

  4. Live demo showcasing the concepts

  5. (interactive) Install Git and a client

  6. (interactive) Set up a repository on GitHub for your P1 project

  7. Exercises (if there's time left)

2 / 32

Why use a version control system (VCS)?

3 / 32

Why use a version control system (VCS)?

  • You have an annotated history of changes
3 / 32

Why use a version control system (VCS)?

  • You have an annotated history of changes

  • It makes collaboration easy

3 / 32

Why use a version control system (VCS)?

  • You have an annotated history of changes

  • It makes collaboration easy

  • It provides you with a full backup of your project

3 / 32

Why use a version control system (VCS)?

  • You have an annotated history of changes

  • It makes collaboration easy

  • It provides you with a full backup of your project

  • Unlike on services like Dropbox, conflicts are structured and easily resolved

3 / 32

Why use a version control system (VCS)?

  • You have an annotated history of changes

  • It makes collaboration easy

  • It provides you with a full backup of your project

  • Unlike on services like Dropbox, conflicts are structured and easily resolved

Why Git, specifically?

3 / 32

Why use a version control system (VCS)?

  • You have an annotated history of changes

  • It makes collaboration easy

  • It provides you with a full backup of your project

  • Unlike on services like Dropbox, conflicts are structured and easily resolved

Why Git, specifically?

  • Distributed (as opposed to centralised)
3 / 32

Why use a version control system (VCS)?

  • You have an annotated history of changes

  • It makes collaboration easy

  • It provides you with a full backup of your project

  • Unlike on services like Dropbox, conflicts are structured and easily resolved

Why Git, specifically?

  • Distributed (as opposed to centralised)

  • Most popular ⟹ all problems have been had

3 / 32

Why use a version control system (VCS)?

  • You have an annotated history of changes

  • It makes collaboration easy

  • It provides you with a full backup of your project

  • Unlike on services like Dropbox, conflicts are structured and easily resolved

Why Git, specifically?

  • Distributed (as opposed to centralised)

  • Most popular ⟹ all problems have been had

  • GitHub

3 / 32

Git concepts (functions)

4 / 32

The main components of a Git repository

5 / 32

Add: stage changes for committing

6 / 32

Commit: append staged changes to history

7 / 32

Push: changes on local repo ⭢ remote repo

8 / 32

Push: changes on local repo ⭢ remote repo (before)

9 / 32

Push: changes on local repo ⭢ remote repo (after)

10 / 32

Pull: changes on remote repo ⭢ local repo (before)

11 / 32

Pull: changes on remote repo ⭢ local repo (after)

12 / 32

Pull: changes on remote repo ⭢ local repo (after)

Fetch

  • "Safe" alternative to push
  • Downloads commits without applying them to the working tree
12 / 32

Branches

  • Branches are simply labels pointing to commits

  • Git uses these labels to move around in the commit history

13 / 32

Branches

  • Branches are simply labels pointing to commits

  • Git uses these labels to move around in the commit history

14 / 32

Branches

  • Branches are simply labels pointing to commits

  • Git uses these labels to move around in the commit history

15 / 32

Checkout: switch to a different branch

16 / 32

Checkout: switch to a different branch

17 / 32

Merge: apply changes from a different branch

18 / 32

Overview

19 / 32

icon GitHub

20 / 32

View and comment on commits

21 / 32

Keep track of tasks with project boards

22 / 32

Workflow

23 / 32

Time for a demo

⤷ on Windows with GitHub Desktop

24 / 32

Time to set up Git and GitHub

⤷ and get your project repository ready to go

25 / 32

Installing Git

Windows and macOS

Download from https://git-scm.com/

Windows users may have to restart after installation to update the system PATH

Linux

Install via package manager, e.g.

sudo apt install git

Installing a client

Many options, but to highlight a few:

GitHub Desktop

⤷ very simple client, only most basic features; integrates with GitHub

GitKraken

⤷ more features, fancy UI; free for non-commercial use, requires account or GitHub sign-in

Your editor of choice

⤷ many editors support version control from inside the editor
(e.g. Emacs with Magit, or Vim with Fugitive)

The command line 😏

26 / 32

Collaborate with GitHub

❗ signing up with uni email ⟹ free private repos

27 / 32

Collaborate with GitHub

❗ signing up with uni email ⟹ free private repos

Getting started

  1. Go to github.com and sign up with your @student.aau.dk email

  2. Go to education.github.com/pack and click Get your Pack

27 / 32

Setting up a repository (for the repo owner)

NB: Only one person from each group needs to set up a project repository

  1. On GitHub, log in and click iconNew

  2. Fill in the details;

    • Repository name: P1
    • Description: P1 project for Group <your group id>
    • 🗹 Private (can be set later, if you don't have the student discount yet)
    • 🗹 Initialize this repository with a README
    • Add .gitignore: TeX
  3. Go to iconSettings 🠪 Collaborators

  4. Add each of your group members as a collaborator

  5. Go to iconCode and click Clone or downloadicon

  6. Click Open in Desktop to get started (or copy the URL and open it with your Git client, if you don't use GitHub Desktop)

28 / 32

Setting up a repository (for the repo owner)

NB: Only one person from each group needs to set up a project repository

  1. Download a template from janusvm.github.io/aau-project-template

  2. Unpack it in the folder where you cloned the project

  3. In GitHub Desktop (or whatever client you use), stage all the new files

  4. Commit with a message like "Add project template files"

  5. Push to GitHub

29 / 32

Setting up a repository (for the collaborators)

  1. Go to the repository page on GitHub (github.com/owner/repo)

  2. Click Clone or download icon

  3. Clone the repository (by clicking Open in Desktop with GH Desktop, or by using the URL with another client)

After this, you're ready to start writing!

30 / 32

Remember the workflow

  1. Pull from GitHub to get the latest changes from the other group members

  2. Work on the project

  3. Add and Commit related changes together

  4. Pull again, in case new commits have been pushed in the meantime

  5. If there are any conflicts, resolve them and commit the merge

  6. Push your changes to GitHub, so the other group members can get them

31 / 32

Exercises

learngitbranching.js.org

Feel free to ask questions too!

32 / 32

Overview of today

2 / 32
Paused

Help

Keyboard shortcuts

, , Pg Up, k Go to previous slide
, , Pg Dn, Space, j Go to next slide
Home Go to first slide
End Go to last slide
Number + Return Go to specific slide
b / m / f Toggle blackout / mirrored / fullscreen mode
c Clone slideshow
p Toggle presenter mode
t Restart the presentation timer
?, h Toggle this help
Esc Back to slideshow