Basics of Version Control Systems · What are VCS Software development perspective Version control...

36
Intro Basics VCS Cheat sheets Basics of Version Control Systems Lars Vilhuber 1 1 Cornell University, Economics Department, August 20-22, 2018: Day 2 Vilhuber Basics of VCS

Transcript of Basics of Version Control Systems · What are VCS Software development perspective Version control...

Intro Basics VCS Cheat sheets

Basics of Version Control Systems

Lars Vilhuber1

1Cornell University, Economics Department,

August 20-22, 2018: Day 2

Vilhuber Basics of VCS

Intro Basics VCS Cheat sheets

What are VCS

Software development perspectiveVersion control systems (VCS) (or Source ConfigurationManagement (SCM) systems ∗) allow developers or authors tokeep track of the history of their projects? source code. [source]

Generic viewDetailed mechanism to manage different versions (historical,parallel) of documents, files, programs, etc.

Vilhuber Basics of VCS

Intro Basics VCS Cheat sheets

What are VCS

Software development perspectiveVersion control systems (VCS) (or Source ConfigurationManagement (SCM) systems ∗) allow developers or authors tokeep track of the history of their projects? source code. [source]

Generic viewDetailed mechanism to manage different versions (historical,parallel) of documents, files, programs, etc.

Vilhuber Basics of VCS

Intro Basics VCS Cheat sheets

You already have it

Implicit uses

I Backup systems (Apple Time Machine, others)I Word processors (Undo feature, Track changes in Word,

finer-grained features in content management systems:Google Docs, Blog software, etc.)

I Versioning filesystemsI Paper books!

Vilhuber Basics of VCS

Intro Basics VCS Cheat sheets

Modern Labor Economics: Theory and Public Policy

Vilhuber Basics of VCS

Intro Basics VCS Cheat sheets

Modern Labor Economics: Theory and Public Policy

Vilhuber Basics of VCS

Intro Basics VCS Cheat sheets

Principal idea

1 First edition

4 Second edition5 Start of work on a

Canadian edition6 Start of work on the next

US edition9 Third edition

10 First Canadian edition

Vilhuber Basics of VCS

Intro Basics VCS Cheat sheets

Principal idea

1 First edition4 Second edition

5 Start of work on aCanadian edition

6 Start of work on the nextUS edition

9 Third edition10 First Canadian edition

Vilhuber Basics of VCS

Intro Basics VCS Cheat sheets

Principal idea

1 First edition4 Second edition5 Start of work on a

Canadian edition

6 Start of work on the nextUS edition

9 Third edition10 First Canadian edition

Vilhuber Basics of VCS

Intro Basics VCS Cheat sheets

Principal idea

1 First edition4 Second edition5 Start of work on a

Canadian edition6 Start of work on the next

US edition

9 Third edition10 First Canadian edition

Vilhuber Basics of VCS

Intro Basics VCS Cheat sheets

Principal idea

1 First edition4 Second edition5 Start of work on a

Canadian edition6 Start of work on the next

US edition9 Third edition

10 First Canadian edition

Vilhuber Basics of VCS

Intro Basics VCS Cheat sheets

Principal idea

1 First edition4 Second edition5 Start of work on a

Canadian edition6 Start of work on the next

US edition9 Third edition

10 First Canadian edition

Vilhuber Basics of VCS

Intro Basics VCS Cheat sheets

File-system based versioning

The most common method... Also used in email versioning...

Remember this?01 01 readBLS.R

02 01 readCensus.R

02 02 prepareCensus.R

03 01 create analysis data.R

04 01 runOLS.sas

README.txt

Vilhuber Basics of VCS

Intro Basics VCS Cheat sheets

File-system based versioning

The most common method... Also used in email versioning...

What if I make changes?

01 01 readBLS.R

02 01 readCensus.R

02 02 prepareCensus.R

03 01 create analysis data.R

04 01 runOLS.sas

README.txt

02 01 readCensus.R.bak

02 01 readCensus V2.R

02 01 readCensus V3.R

02 01 readCensus V3-jma.R

02 01 readCensus V3-jma-rm.R

Vilhuber Basics of VCS

Intro Basics VCS Cheat sheets

File-system based versioning

The most common method... Also used in email versioning...

What if I make changes?

01 01 readBLS.R

02 01 readCensus.R

02 02 prepareCensus.R

03 01 create analysis data.R

04 01 runOLS.sas

README.txt

02 01 readCensus.R.bak

02 01 readCensus V2.R

02 01 readCensus V3.R

02 01 readCensus V3-jma.R

02 01 readCensus V3-jma-rm.R

Vilhuber Basics of VCS

Intro Basics VCS Cheat sheets

File-system based versioning

The most common method... Also used in email versioning...

What if I make changes?

01 01 readBLS.R

02 01 readCensus.R

02 02 prepareCensus.R

03 01 create analysis data.R

04 01 runOLS.sas

README.txt

02 01 readCensus.R.bak

02 01 readCensus V2.R

02 01 readCensus V3.R

02 01 readCensus V3-jma.R

02 01 readCensus V3-jma-rm.R

Vilhuber Basics of VCS

Intro Basics VCS Cheat sheets

File-system based versioning

The most common method... Also used in email versioning...

What if I make changes?

01 01 readBLS.R

02 01 readCensus.R

02 02 prepareCensus.R

03 01 create analysis data.R

04 01 runOLS.sas

README.txt

02 01 readCensus.R.bak

02 01 readCensus V2.R

02 01 readCensus V3.R

02 01 readCensus V3-jma.R

02 01 readCensus V3-jma-rm.R

Vilhuber Basics of VCS

Intro Basics VCS Cheat sheets

File-system based versioning

The most common method... Also used in email versioning...

What if I make changes?

01 01 readBLS.R

02 01 readCensus.R

02 02 prepareCensus.R

03 01 create analysis data.R

04 01 runOLS.sas

README.txt

02 01 readCensus.R.bak

02 01 readCensus V2.R

02 01 readCensus V3.R

02 01 readCensus V3-jma.R

02 01 readCensus V3-jma-rm.R

Vilhuber Basics of VCS

Intro Basics VCS Cheat sheets

File-system based versioning

The most common method... Also used in email versioning...

What if I make changes?

01 01 readBLS.R

02 01 readCensus.R

02 02 prepareCensus.R

03 01 create analysis data.R

04 01 runOLS.sas

README.txt

02 01 readCensus.R.bak

02 01 readCensus V2.R

02 01 readCensus V3.R

02 01 readCensus V3-jma.R

02 01 readCensus V3-jma-rm.R

Vilhuber Basics of VCS

Intro Basics VCS Cheat sheets

Better way

Is there a better way?

Vilhuber Basics of VCS

Intro Basics VCS Cheat sheets

History

Vilhuber Basics of VCS

Intro Basics VCS Cheat sheets

Two major types of version-management

Centralized modelServer-client approach, editors check out a copy, modify it, andcheck it back in. Multiple editors:I File locking: only one person can check out any given fileI Version merging: discrepancies are handled upon checkin

Distributed modelThere is no central server (prescribed by software). Everyeditor has a full copy of all version, synchronisation occurs byexchanging patches.

Vilhuber Basics of VCS

Intro Basics VCS Cheat sheets

Two major types of version-management

Centralized modelServer-client approach, editors check out a copy, modify it, andcheck it back in. Multiple editors:I File locking: only one person can check out any given fileI Version merging: discrepancies are handled upon checkin

Distributed modelThere is no central server (prescribed by software). Everyeditor has a full copy of all version, synchronisation occurs byexchanging patches.

Vilhuber Basics of VCS

Intro Basics VCS Cheat sheets

Focus in this class

We will focus on Git:I Subversion (centralized) - still broadly in use, but no longer

supported at CornellI Git (decentralized) - Hautahi

Windows TortoiseGit (free)OSX installed (Xcode) upon first useLinux typically integrated

with various semi-specialized graphical versions (Githubclient, etc.)

Vilhuber Basics of VCS

Intro Basics VCS Cheat sheets

THE reference for Git

git-scm.com/book/en/v2

Vilhuber Basics of VCS

Intro Basics VCS Cheat sheets

Learning more

Numerous resources on the webI https://try.github.io/

I https://www.atlassian.com/git/tutorials

Vilhuber Basics of VCS

Intro Basics VCS Cheat sheets

Tracking history

What happened? And who did what?One of the key advantages of using version control systems is... to control versions.I Straightforward to view multiple versions of a file

(assuming proper usage)I Possibility to view who changed what (“blame” or

“annotate”)

Vilhuber Basics of VCS

Intro Basics VCS Cheat sheets

Tracking using web interfaces: SVN

Vilhuber Basics of VCS

Intro Basics VCS Cheat sheets

Tracking using web interfaces: SVN

Vilhuber Basics of VCS

Intro Basics VCS Cheat sheets

Tracking using web interfaces: SVN

Vilhuber Basics of VCS

Intro Basics VCS Cheat sheets

Tracking using web interfaces: SVN

Vilhuber Basics of VCS

Intro Basics VCS Cheat sheets

Tracking using web interfaces: git

Vilhuber Basics of VCS

Intro Basics VCS Cheat sheets

Tracking using web interfaces: git

Vilhuber Basics of VCS

Intro Basics VCS Cheat sheets

Tracking using web interfaces: git

Vilhuber Basics of VCS

Intro Basics VCS Cheat sheets

VCS infrastructure

At CornellCornell Sourceforge (obsolete as of Sept 30, 2018)

ElsewhereI GitHub (Git, subversion, free for open-source and

academic users)I BitBucket (Git, no subversion, free for academic users)I Roll your own: no server required for Git on your PC

Vilhuber Basics of VCS

Intro Basics VCS Cheat sheets

I Git command-line cheat sheetI Xcode cheat sheet (for Mac users)

Vilhuber Basics of VCS