1 of 23

Introduction to GitHub

000

2 of 23

Goals

2

    • Understand why we use version control

    • Understand GitHub basic commands

    • Be able to use GitHub for your projects

3 of 23

What is version control?

  • "...the management of changes to documents, computer programs, large web sites, and other collections of information." ~ Wikipedia, Version control

3

4 of 23

What is Git?

  • "...a distributed version-control system for tracking changes in source code during software development." ~ Wikipedia, Git

4

5 of 23

Benefits of using Git

modified from SEAMS

  • Roll-back: access to previous versions (while keeping your directories neat)
  • Tracking: easily compare versions
  • Accountability: see who did what and when
  • Branching: have both working and development versions without duplication
  • Comprehensibility: document changes with helpful comments

5

6 of 23

6

Distributed version control system

Repository

(Local disk)

push

pull

Working copy

update

add 🡪

commit

Tumelo

Repository

(Server)

Repository

(Local disk)

push

pull

Working copy

update

add 🡪

commit

Evans

Repository

(Local disk)

push

pull

Working copy

update

add 🡪

commit

Lauren

7 of 23

Getting started on GitHub

  • Command line (Git Bash, terminal)
  • GitHub Desktop
  • GitKraken

7

8 of 23

Getting started with your terminal

  • pwd

Prints current working directory

  • cd

Change directory

  • mkdir

Make directory

8

9 of 23

Exercise 1

  • Open a terminal / Git bash
  • Figure out where you are (eg: pwd)
  • Navigate to the directory where you will store your MMED files (eg: cd path)
  • Create directory for the git session (eg: mkdir MMEDGit)
  • Change into the directory (eg: cd MMEDGit)

9

10 of 23

Getting started on GitHub

  • git clone

Clone a remote repository to your local computer

  • cd

Change directory

  • cd ..

Change directory one up

10

11 of 23

Exercise 2

  • on Github: Fork the repository - this gives you a copy you control

  • Clone your fork repository to an appropriate location on your local machine (eg: git clone https://github.com/ICI3D/Sandbox.git)

  • Change into the directory of the cloned repository (eg: cd Sandbox)

11

12 of 23

Getting started on GitHub

  • git pull

Pulls recently modified files from the remote repository to the local repository

  • git status

Info about modified files

  • git add file1 file2

stages the changes you made

  • git commit –m “descriptive message”

Commits staged files

12

13 of 23

Exercise 3

  • Check the status of your repo (eg: git status)
  • Open Participants2023_XXX.md with notepad

Edit file

Rename it as <your name>.md

Save file

  • Check status (git status)
  • Add name.md (eg: git add name.md)
  • Commit files (eg: git commit –m “message”)

13

14 of 23

Getting started on GitHub

  • git pull
    • Pulls recently modified files from the remote repository to the local repository

  • git push
    • Pushes files to remote repository

14

15 of 23

Exercise 4

  • Pull files from your remote repo to the local repo (eg: git pull)
  • Push the modified files to the remote repo (eg: git push)

15

16 of 23

Git commands chart

16

Repository

(Server)

Repository

(Local disk)

push

pull

Working copy

update

add 🡪

commit

clone

17 of 23

CONFLICT RESOLUTION

17

18 of 23

CONFLICT RESOLUTION

18

19 of 23

CONFLICT RESOLUTION

  • pull = fetch + merge
  • fetch always works (gets the information)
  • merge usually works
  • if it doesn't work, you have a conflict and you should try to resolve it:

identify conflicted files

edit them (however you usually edit files, or with nano)

fix them

add them (with add or at the same time as commit with -a)

  • commit
  • You should generally pull and make sure the merge is OK before you push.

19

20 of 23

Each time you're ready to start working

  • Pull changes from origin/master (git pull)

If you're following the workflow there should not be conflicts, but if there are, see below

  • Work on your files

20

21 of 23

Each time you're ready to add content to the master branch

  • Add and commit the changes that are ready for inclusion in origin/master (eg: git add <newfilesifany>; git commit -m '<your commit message>')
  • Pull changes from origin/master (git pull)
  • While there are conflicts

Resolve conflicts

Add and commit the new changes

  • Push the changes to origin/master (git push)

21

22 of 23

Troubleshoot

22

23 of 23

This presentation is made available through a Creative Commons Attribution-Noncommercial license. Details of the license and permitted uses are available at� http://creativecommons.org/licenses/by-nc/3.0/

Title: {Introduction to GitHub}

Attribution: {Zinhle Mthombothi, Jonathan Dushoff & Juliet Pulliam}, Clinic on the Meaningful Modeling of Epidemiological Data

Source URL: {FIGSHARE URL}

For further information please contact admin@ici3d.org.

000

© {2019} International Clinics on Infectious Disease Dynamics and Data

000

000