18
Version Control for Scientists Thomas K. Baldwin

Version Control for Scientists · 2016-05-26 · Collaborating with git You can share commit privileges with others, and both collaborate on the same repository. • Use github as

  • Upload
    others

  • View
    6

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Version Control for Scientists · 2016-05-26 · Collaborating with git You can share commit privileges with others, and both collaborate on the same repository. • Use github as

Version Control for Scientists

Thomas K. Baldwin

Page 2: Version Control for Scientists · 2016-05-26 · Collaborating with git You can share commit privileges with others, and both collaborate on the same repository. • Use github as

Version Control is an organizational skill

• keep files in order

• keep files backed up

• collaborate

for computer programs, papers, presentations…

Page 3: Version Control for Scientists · 2016-05-26 · Collaborating with git You can share commit privileges with others, and both collaborate on the same repository. • Use github as

• nvpaper.doc

• nvpaper_1.doc

• nvpaper_1_hailin.doc

• nvpaper_2.doc

• nvpaper_2.1.doc

• nvpaper_2.1_naturephysics.doc

• nvpaper_final.doc

• nvpaper_final_submitted.doc

Page 4: Version Control for Scientists · 2016-05-26 · Collaborating with git You can share commit privileges with others, and both collaborate on the same repository. • Use github as
Page 5: Version Control for Scientists · 2016-05-26 · Collaborating with git You can share commit privileges with others, and both collaborate on the same repository. • Use github as

You’re Reinventing the Wheel

The solution exists, and it is called Version Control

• a program that keeps track of files as they change

• invented for software development, but useful for any set of changing files

Page 6: Version Control for Scientists · 2016-05-26 · Collaborating with git You can share commit privileges with others, and both collaborate on the same repository. • Use github as

Version control programs

• Distributed: Git, Mercurial (hg), Bazaar (bzr)

• older: Subversion (svn), CVS, RCS

• Built-in to some file formats (e.g. Word)

The emerging standard is git.

Page 7: Version Control for Scientists · 2016-05-26 · Collaborating with git You can share commit privileges with others, and both collaborate on the same repository. • Use github as

The Repository• A folder with stored

history

• past versions stored in hidden subfolder (.hg or .git)

• only added files are tracked

• snapshots are saved when you make a commit

Page 8: Version Control for Scientists · 2016-05-26 · Collaborating with git You can share commit privileges with others, and both collaborate on the same repository. • Use github as

CommitsA snapshot of tracked files at a point in time.

• a unique identifier (SHA1 hash)

• a link to parent commit

• name of author/committer

• a descriptive message

The commit message should briefly describe how the snapshot differs from

the parent.

Page 9: Version Control for Scientists · 2016-05-26 · Collaborating with git You can share commit privileges with others, and both collaborate on the same repository. • Use github as
Page 10: Version Control for Scientists · 2016-05-26 · Collaborating with git You can share commit privileges with others, and both collaborate on the same repository. • Use github as

Demo

Page 11: Version Control for Scientists · 2016-05-26 · Collaborating with git You can share commit privileges with others, and both collaborate on the same repository. • Use github as

baldwint.com/vcs/important.tex

• Make a repository containing this file

• Add the file and make an initial commit

• Fix typos and commit

• Change author and commit

• Change date and commit

Page 12: Version Control for Scientists · 2016-05-26 · Collaborating with git You can share commit privileges with others, and both collaborate on the same repository. • Use github as

Advanced Topics

• keep files in order

• keep files backed up

• collaborate

Page 13: Version Control for Scientists · 2016-05-26 · Collaborating with git You can share commit privileges with others, and both collaborate on the same repository. • Use github as

Branches and Merges

branches: for dead ends merges: for software dev

clones / forks: wholesale copies of a repository

A B C

D E

F G

A B C

D E

F G’

Page 14: Version Control for Scientists · 2016-05-26 · Collaborating with git You can share commit privileges with others, and both collaborate on the same repository. • Use github as

Cloning, Pushing, Pulling

• Cloning copies a repository and its history.

• This creates a fork. (it’s a backup!)

• A push transfers changes from a local repository to a remote one. (A pull is the opposite of a push.)

• Pushes and pulls are done one branch at a time.

Page 15: Version Control for Scientists · 2016-05-26 · Collaborating with git You can share commit privileges with others, and both collaborate on the same repository. • Use github as

github.com

• clone your practice repository to github (“publish”)

• View it on the web

• Make a change to the local repository and commit it

• Is it on the web?

• push (“sync”) your new change to the remote copy

Page 16: Version Control for Scientists · 2016-05-26 · Collaborating with git You can share commit privileges with others, and both collaborate on the same repository. • Use github as

Collaborating with git

You can share commit privileges with others, and both collaborate on the same repository.

• Use github as an “official copy” and pull frequently

• If working simultaneously, use branches.

You can always commit to your own forks, but you’ll need commit privileges to push them back.

Page 17: Version Control for Scientists · 2016-05-26 · Collaborating with git You can share commit privileges with others, and both collaborate on the same repository. • Use github as

github.com/baldwint/uomlweb

• clone this repository to your computer

• Make a change and commit it

• one at a time, push your change to the remote copy

• I have no idea if this will work

Page 18: Version Control for Scientists · 2016-05-26 · Collaborating with git You can share commit privileges with others, and both collaborate on the same repository. • Use github as

Pro Git (free, official ebook): https://progit.org

Git for scientists: http://nyuccl.org/pages/gittutorial/

Try git without installing: https://try.github.io/