1 of 54

Distributed Revision Control

Alexander Bernauer

2 of 54

Outline

  • Revision Control
  • Centralized vs. Distributed
  • git

3 of 54

Part 1:

Revision Control

4 of 54

Motivation

  • I need the latest version that works.
  • What is different now?
  • Which change introduced the bug?
  • Who wrote this code?
  • How to collaborate with others?
  • How to manage security fixes for a release.
  • I want to add a new feature but stay synced with the main development.

5 of 54

Big Picture

  • History
  • Code Management
  • Release Management
  • Team Management

6 of 54

Basic Terms

  • Repository
  • Commit
  • Revision
  • Branch
  • Merge
  • Working Copy

7 of 54

Part 2:

Centralized vs. Distributed

8 of 54

The Usual Subjects

Centralized

CVS

Distributed

9 of 54

Centralized

10 of 54

Problems

11 of 54

Decentralized

12 of 54

Example:

Open Source Project

fetch

public repository

main

developer

push

external

contributor

fetch

public

fork

push

13 of 54

Part 3:

git

14 of 54

Repository

  • Objects
    • Commits
    • Trees
    • BLOBs
    • Tags
  • References
    • Tags
    • Branches
    • Remotes
  • optionally: working copy
    • HEAD

15 of 54

File Status Lifecycle

16 of 54

Stages

working

copy

index

repository

remote

push/fetch

commit

add

checkout

17 of 54

Demo

18 of 54

References

master

19 of 54

References

master

v 1.0

20 of 54

References

master

v 1.0

feature X

21 of 54

References

master

v 1.0

feature X

22 of 54

References

master

v 1.0

feature X

23 of 54

References

master

v 1.0

feature X

24 of 54

References

master

v 1.0

feature X

v 1.1

25 of 54

References

master

v 1.0

feature X

v 1.1

26 of 54

References

master

v 1.0

feature X

v 1.1

27 of 54

References

master

v 1.0

feature X

feature Y

v 1.1

28 of 54

References

master

v 1.0

feature X

feature Y

v 1.1

29 of 54

References

master

v 1.0

feature X

feature Y

v 1.1

remotes/frank/feature Y

30 of 54

References

master

v 1.0

feature X

feature Y

v 1.1

remotes/frank/feature Y

31 of 54

References

master

v 1.0

feature X

v 1.1

remotes/frank/feature Y

32 of 54

References

master

v 1.0

feature X

v 1.1

33 of 54

References

master

v 1.0

feature X

v 1.1

34 of 54

References

master

v 1.0

feature X

v 1.1

35 of 54

References

master

v 1.0

v 1.1

36 of 54

References

master

v 1.0

v 1.1

v 2.0

37 of 54

References

master

v 1.0

v 1.1

v 2.0

38 of 54

Objects

  • Size
  • Type
    • BLOB (binary large object)
    • Tree (directory)
    • Commit
    • Tag
  • SHA1 ID

39 of 54

BLOB

40 of 54

Tree

41 of 54

Commit

42 of 54

43 of 54

Tag

44 of 54

I need the latest version that works

$ git checkout master

$ git checkout v1.0

45 of 54

What is different now?

$ git log master..HEAD

$ git diff 924ee25

46 of 54

Which change introduced the bug?

$ git bisect start d5ddff1 HEAD

$ git bisect good

$ git bisect bad

$ git bisect run <cmd>

47 of 54

Who wrote this code?

$ git show cb0192d

$ git log -- foo.c

$ git blame foo.c

48 of 54

How to collaborate with others?

$ git clone http://...

$ git branch feature_x

<create commits>

$ git remote add peter git@...

$ git pull peter feature_x

49 of 54

How to manage security fixes for a release?

$ git checkout v1.3.0

$ git cherry-pick a5bd83f

$ git tag -a v1.3.1

$ git push origin v1.3.1

50 of 54

Add a new feature but stay synced with upstream

$ git branch feature_x

<edit files>

$ git add .

$ git commit

$ git fetch upstream

$ git merge upstream/master

51 of 54

More features

  • History Rewriting
    • Changing/Amending/Reordering/Splitting/Squashing
    • Remove a file from every commit
    • Change E-Mail addresses globally
  • Reverting
  • Interactive staging
  • Reflog
  • Submodules/Subtree merging
  • git svn
  • hooks
  • ...

52 of 54

git...

  • ...encourages you to
    • have one commit per logical change
    • have one branch per logical development
  • ...is a toolbox
    • resemble centralized systems
    • integration manager
    • subsystem maintainers
  • ...is very flexible
    • "you should have done X before" does not exist

53 of 54

References

http://gitready.com/

Git Magic

54 of 54

Sources

  • http://de.wikipedia.org/wiki/Client-Server-Modell
  • http://www.iconfinder.com/ajax/download/png/?id=41987&s=128
  • http://www.iconfinder.com/ajax/download/png/?id=7891&s=128
  • http://upload.wikimedia.org/wikipedia/en/7/79/Subversion.png
  • http://upload.wikimedia.org/wikipedia/commons/e/e0/Git-logo.svg
  • http://upload.wikimedia.org/wikipedia/commons/9/9a/New_Mercurial_logo.svg
  • http://upload.wikimedia.org/wikipedia/en/5/5e/GNU_arch_logo.png
  • http://upload.wikimedia.org/wikipedia/commons/4/4c/Darcs-logo.png
  • http://www.perforce.com/sites/default/files/perforce_logo.gif
  • http://www.iconfinder.com/ajax/download/png/?id=49347&s=64
  • http://www.iconfinder.com/ajax/download/png/?id=10593&s=48
  • http://upload.wikimedia.org/wikipedia/commons/3/3f/P2P-network.svg
  • http://www.alexgirard.com/git-book
  • http://www.iconfinder.com/ajax/download/png/?id=24022&s=128
  • http://git-scm.com/images/pro-git-118x157.jpg
  • http://upload.wikimedia.org/wikipedia/commons/b/b3/GitHub.svg
  • http://upload.wikimedia.org/wikipedia/en/9/93/Gitorious.png
  • http://upload.wikimedia.org/wikipedia/en/c/c1/Bazaar_logo_%28software_product%29.svg
  • http://git-scm.com/figures/18333fig0201-tn.png