Version Control with Git Before we start Sign up at github.com 1 - - PowerPoint PPT Presentation

version control with git
SMART_READER_LITE
LIVE PREVIEW

Version Control with Git Before we start Sign up at github.com 1 - - PowerPoint PPT Presentation

Version Control with Git Before we start Sign up at github.com 1 What is Version Control? (AKA revision control, source control) Tracks changes to files Any file can be tracked Text (.txt, .csv, .py, .c, .r etc.) works best


slide-1
SLIDE 1

Version Control with Git

  • Before we start
  • Sign up at github.com

1

slide-2
SLIDE 2

What is Version Control?

(AKA revision control, source control)

  • Tracks changes to files
  • Any file can be tracked
  • Text (.txt, .csv, .py, .c, .r etc.) works best
  • These allow smart difg / merge etc.

2

slide-3
SLIDE 3

Why Use Version Control? #1

3

  • A more efgicient

backup

  • Reproducibility
slide-4
SLIDE 4

Why Use Version Control? #2

4

  • Teamwork
slide-5
SLIDE 5

Version Control Tracks Changes

  • Changes are tracked sequentially

5

slide-6
SLIDE 6

Version Control Tracks Changes

  • Difgerent versions can be saved

6

slide-7
SLIDE 7

Version Control Tracks Changes

  • Multiple versions can be merged

7

slide-8
SLIDE 8

Version Control Alternatives

  • Subversion (svn) - Centralised
  • Mercurial (hg) - Distributed
  • Git (git) – Distributed
  • Most widely used in academia!
  • N.B. GitHub != git
  • Alternatives like GitLab exist

8

slide-9
SLIDE 9

Local Configuration

  • git config

11

slide-10
SLIDE 10

Getting Demo Files

  • git clone

https://github.com/sofuwaresaved/2020- 04-30-ramp-swc

11

slide-11
SLIDE 11

Creating a Repository

  • git init
  • git status

12

slide-12
SLIDE 12

Tracking Changes to Files

  • git add
  • git commit

13

slide-13
SLIDE 13

Git – add and commit

17 Workspace Staging Area Local Repo Visible File System Git Repository add commit

slide-14
SLIDE 14

Exploring History #1

  • git log
  • git difg

15

slide-15
SLIDE 15

Git – difg #1

17 Workspace Staging Area Local Repo Visible File System Git Repository diff diff --staged

slide-16
SLIDE 16

Git – difg #2

17 Workspace Staging Area Local Repo Visible File System Git Repository diff HEAD

sl33v51a f22b25e g31a45d

HEAD HEAD ~1 HEAD ~2 diff sl33v51a

slide-17
SLIDE 17

Restoring Files

  • git checkout

15

slide-18
SLIDE 18

Git - restoration

17 Workspace Staging Area Local Repo Visible File System Git Repository

sl33v51a f22b25e g31a45d

checkout f22b25e

f22b25e

HEAD HEAD ~1 HEAD ~2 checkout HEAD

g31a45d

slide-19
SLIDE 19

Git Workflow – Local Repo.

17

slide-20
SLIDE 20

Collaboration

17

Sarah's computer /home/sarah/planets Fred's computer /home/fred/planets

A B

slide-21
SLIDE 21

Collaboration: Remote Repositories

  • Sign in https://github.com/
  • Create repository
  • git remote add
  • git push
slide-22
SLIDE 22

Collaboration: Branches

slide-23
SLIDE 23

Collaboration: Creating Branches

  • git branch dev
  • git checkout dev
slide-24
SLIDE 24

Collaboration: Creating Branches 2

  • Create rainfall_conversion.py
  • git add rainfall_conversion.py
  • git commit -m
slide-25
SLIDE 25

Git Workflow – Remote Repo.

21

slide-26
SLIDE 26

Collaboration: Branches

slide-27
SLIDE 27

Collaboration: Feature Branch Exercise

  • Check out ‘dev’
  • Create a new branch called ‘docs’
  • Create and add README.md
  • Push to GitHub and merge back to ‘dev’
  • Pull the changes back to your computer
slide-28
SLIDE 28

What next?

  • Ignore files / Merging
  • https://sofuware-carpentry.org

22