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

Version Control Will Save Your Life

Alessandro Gasparini
<ag475@leicester.ac.uk>

May 16th, 2018

Health Sciences Postgraduate Forum 2018

1 of 13

What is version control?

[...] version control [...] is the management of changes to documents, computer programs, large web sites, and other collections of information

Source: https://en.wikipedia.org/wiki/Version_control

2 of 13

What is version control?

[...] version control [...] is the management of changes to documents, computer programs, large web sites, and other collections of information

Source: https://en.wikipedia.org/wiki/Version_control

Changes are usually identified by a number or letter code, termed the "revision number", "revision level", or simply "revision". For example, an initial set of files is "revision 1". When the first change is made, the resulting set is "revision 2", and so on.

2 of 13

What is version control?

[...] version control [...] is the management of changes to documents, computer programs, large web sites, and other collections of information

Source: https://en.wikipedia.org/wiki/Version_control

Changes are usually identified by a number or letter code, termed the "revision number", "revision level", or simply "revision". For example, an initial set of files is "revision 1". When the first change is made, the resulting set is "revision 2", and so on.

Each revision is associated with a timestamp and the person making the change. Revisions can be compared, restored, and with some types of files, merged.

2 of 13

Why version control?

  1. Backup (sort of);

  2. Versioning;

  3. Contributing to open source projects;

  4. Reproducibility and trasparency in science [doi: 10.1186/1751-0473-8-7].

3 of 13

So Why Do We Need A Version Control System (VCS)?

Our shared folder/naming system is fine for class projects or one-time papers. But software projects? Not a chance. A good VCS does the following:

  • Backup and Restore: Files are saved as they are edited, and you can jump to any moment in time. Need that file as it was on Feb 23, 2007? No problem.
  • Synchronization: Lets people share files and stay up-to-date with the latest version.
  • Short-term undo: Monkeying with a file and messed it up? (That’s just like you, isn’t it?). Throw away your changes and go back to the “last known good” version in the database.
  • Long-term undo: Sometimes we mess up bad. Suppose you made a change a year ago, and it had a bug. Jump back to the old version, and see what change was made that day.
  • Track Changes: As files are updated, you can leave messages explaining why the change happened (stored in the VCS, not the file). This makes it easy to see how a file is evolving over time, and why.
  • Track Ownership: A VCS tags every change with the name of the person who made it. Helpful for blamestorming giving credit.
  • Sandboxing, or insurance against yourself: Making a big change? You can make temporary changes in an isolated area, test and work out the kinks before “checking in” your changes.
  • Branching and merging: A larger sandbox. You can branch a copy of your code into a separate area and modify it in isolation (tracking changes separately). Later, you can merge your work back into the common area.

Backup and versioning

Source: http://smutch.github.io/VersionControlTutorial/

4 of 13

Backup and versioning

The fundamental idea of version control is to manage multiple revisions of the same unit of information. The idea of backup is to copy the latest version of information to a safe place, where it may be used to restore the original after a data loss event.

5 of 13

Backup and versioning

The fundamental idea of version control is to manage multiple revisions of the same unit of information. The idea of backup is to copy the latest version of information to a safe place, where it may be used to restore the original after a data loss event.

Source: http://geek-and-poke.com/ and me, just a few years ago

5 of 13

With version control we actually preserve the history of all changes to a file! In a single file! Whoop whoop! This is bad: 1- using a VCS is more elegant, there is a single file "script.R" 2- automatic diff tools 3- no need to actually open all files

Backup and versioning

What kind of content is suitable for version control?

  • Data-cleaning script;

  • Analysis script;

  • Manuscript draft;

  • ...any text-based document, really!

6 of 13

Backup and versioning

What kind of content is suitable for version control?

  • Data-cleaning script;

  • Analysis script;

  • Manuscript draft;

  • ...any text-based document, really!

Do you write any kind of software?

Do you analyse data using R/Stata/SAS/SPSS/...?

Do you write documents in LaTeX/Markdown?

Do you use Bash scripts on ALICE/SPECTRE?

You need version control!

6 of 13

Collaboration

The headache way:

7 of 13

Collaboration

The headache way:

The Version Control System (VCS) way:

https://wac-cdn.atlassian.com/dam/jcr:0869c664-5bc1-4bf2-bef0-12f3814b3187/01.svg

  • Each collaborator can suggest changes;

  • Each change can be merged into the main project by the person in charge;

  • Resolving conflicts is easy (-ish).

7 of 13

Contributing to open source projects

8 of 13

Contributing to open source projects

8 of 13

Contributing to open source projects

8 of 13

Version control systems [VCS]

Source: https://homes.cs.washington.edu/~mernst/advice/version-control.html

Popular VCS:

Git, Mercurial (Hg), Subversion (SVN), ...

9 of 13

Git

Why Git?

  • Git is good:

    1. Performance
    2. Security
    3. Flexibility
  • Git is a de-facto standard;

  • GitHub (and Bitbucket, GitLab, ...)!

  • Loads of tutorials online.

10 of 13

Git workflow

Source: https://www.silverpeas.org/

11 of 13

Git is hard though...

Some references:

12 of 13

Take-home message

Version control will not actually save your life...

13 of 13

Take-home message

Version control will not actually save your life...

... but if:

  1. you stick with it, and

  2. you fight through, and

  3. you deal with the occasional quirks

... it will make your (research) life easier (and safer)!

13 of 13

Take-home message

Version control will not actually save your life...

... but if:

  1. you stick with it, and

  2. you fight through, and

  3. you deal with the occasional quirks

... it will make your (research) life easier (and safer)!

Thank you for listening!

13 of 13

What is version control?

[...] version control [...] is the management of changes to documents, computer programs, large web sites, and other collections of information

Source: https://en.wikipedia.org/wiki/Version_control

2 of 13
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