際際滷

際際滷Share a Scribd company logo
Version Control
Based on the materials by
Mike Jackson, Katy Huff, Paul Ivanov, Rachel Slaybaugh, Anthony
Scopatz, and Greg Wilson
Copyright 息 Software Carpentry 2013
This work is licensed under the Creative Commons Attribution License
See http://software-carpentry.org/license.html for more information.
With version control we can
 Keep track of changes like a lab notebook for code
and documents
 Roll back changes to any point in the history of
changes to our files
 Back up our entire history of changes in various
locations
 Work on our files from multiple locations
 Identify and resolve conflicts when the same file is
edited within two repositories without losing any work
 Collaboratively work on code or documents or any
other files
http://software-carpentry.org
Different version control systems
 Centralized version control, for example SVN
 Distributed version control, for example
Mercurial or Git
 Remote repositories hosting services, for
example GitHub and BitBucket
 Ask about a repository at your research
institution!

http://software-carpentry.org
Git


Distributed version control



Very powerful



Widely used



May seem a steep learning curve but its well worth it!

http://software-carpentry.org
Distributed version control
Local
Working
copy

commit

Remote
push

add
checkout

pull

Staging area (git add.)
http://software-carpentry.org
Commits

i87hks

hni686ad

commi
t

abjgd687

commi
t

khd76enak

commi
t

HEAD

http://software-carpentry.org
Commits - checkouts

i87hks

hni686ad

abjgd687

commi
t

commi
t

khd76enak

commi
t

git checkout hni686ad
HEAD

http://software-carpentry.org
Branching
MASTER
i87hks

hni686ad
commi
t

abjgd687
commi
t

khd76enak
commi
t

branch (git checkout b feature1)

commi
t
FEATURE1

http://software-carpentry.org
Merging a branch
MASTER
abjgd687

hni686ad

i87hks
commi
t

commi
t

branch (git checkout b feature1)

khd76enak
commi
t

git merge feature1

commi
t

FEATURE1

http://software-carpentry.org
Working with remote repository
Local
Working
copy

commit

checkout

My laptop

Remote
push

pull

GitHub

http://software-carpentry.org
Working with remote repository
Remote

pull

push
pull
Working
copy

commit

push
Working
copy

commit

checkout

checkout

Aleksandra

John
http://software-carpentry.org
Workflows and best practices

 Thinking about joining and contributing to
project that uses a version control?
 Check their workflow and recommended
practice (for example, each new feature in a
new branch).
 If in doubt, ask questions!

http://software-carpentry.org

More Related Content

Software Carpentry - Version control slides