Decentralized Version Control Systems Matthieu Moy Verimag 2007 - - PowerPoint PPT Presentation

decentralized version control systems
SMART_READER_LITE
LIVE PREVIEW

Decentralized Version Control Systems Matthieu Moy Verimag 2007 - - PowerPoint PPT Presentation

Prehistory History Linux Git Conclusion Decentralized Version Control Systems Matthieu Moy Verimag 2007 Matthieu Moy (Verimag) DVC 2007 < 1 / 43 > Prehistory History Linux Git Conclusion Outline Motivations, Prehistory 1


slide-1
SLIDE 1

Prehistory History Linux Git Conclusion

Decentralized Version Control Systems

Matthieu Moy

Verimag

2007

Matthieu Moy (Verimag) DVC 2007 < 1 / 43 >

slide-2
SLIDE 2

Prehistory History Linux Git Conclusion

Outline

1

Motivations, Prehistory

2

History and Categories of Version Control Systems

3

Version Control for the Linux Kernel

4

Git: One Decentralized Revision Control System

5

Conclusion

Matthieu Moy (Verimag) DVC 2007 < 2 / 43 >

slide-3
SLIDE 3

Prehistory History Linux Git Conclusion

Outline

1

Motivations, Prehistory

2

History and Categories of Version Control Systems

3

Version Control for the Linux Kernel

4

Git: One Decentralized Revision Control System

5

Conclusion

Matthieu Moy (Verimag) DVC 2007 < 3 / 43 >

slide-4
SLIDE 4

Prehistory History Linux Git Conclusion

Backups: The Old Good Time

Basic problems:

◮ “Oh, my disk crashed.” / “Someone has stolen my laptop!” ◮ “@#%!!, I’ve just deleted this important file!” ◮ “Oops, I introduced a bug a long time ago in my code, how can I see

how it was before?”

Matthieu Moy (Verimag) DVC 2007 < 4 / 43 >

slide-5
SLIDE 5

Prehistory History Linux Git Conclusion

Backups: The Old Good Time

Basic problems:

◮ “Oh, my disk crashed.” / “Someone has stolen my laptop!” ◮ “@#%!!, I’ve just deleted this important file!” ◮ “Oops, I introduced a bug a long time ago in my code, how can I see

how it was before?”

Historical solutions:

Matthieu Moy (Verimag) DVC 2007 < 4 / 43 >

slide-6
SLIDE 6

Prehistory History Linux Git Conclusion

Backups: The Old Good Time

Basic problems:

◮ “Oh, my disk crashed.” / “Someone has stolen my laptop!” ◮ “@#%!!, I’ve just deleted this important file!” ◮ “Oops, I introduced a bug a long time ago in my code, how can I see

how it was before?”

Historical solutions:

◮ Replicate:

$ cp -r ~/project/ ~/backup/

Matthieu Moy (Verimag) DVC 2007 < 4 / 43 >

slide-7
SLIDE 7

Prehistory History Linux Git Conclusion

Backups: The Old Good Time

Basic problems:

◮ “Oh, my disk crashed.” / “Someone has stolen my laptop!” ◮ “@#%!!, I’ve just deleted this important file!” ◮ “Oops, I introduced a bug a long time ago in my code, how can I see

how it was before?”

Historical solutions:

◮ Replicate:

$ cp -r ~/project/ ~/backup/

◮ Keep history:

$ cp -r ~/project/ ~/backup/project-2006-10-4

Matthieu Moy (Verimag) DVC 2007 < 4 / 43 >

slide-8
SLIDE 8

Prehistory History Linux Git Conclusion

Backups: The Old Good Time

Basic problems:

◮ “Oh, my disk crashed.” / “Someone has stolen my laptop!” ◮ “@#%!!, I’ve just deleted this important file!” ◮ “Oops, I introduced a bug a long time ago in my code, how can I see

how it was before?”

Historical solutions:

◮ Replicate:

$ cp -r ~/project/ ~/backup/

◮ Keep history:

$ cp -r ~/project/ ~/backup/project-2006-10-4

◮ Keep a description of history:

$ echo "Description of current state" > \ ~/backup/project-2006-10-4/README.txt

Matthieu Moy (Verimag) DVC 2007 < 4 / 43 >

slide-9
SLIDE 9

Prehistory History Linux Git Conclusion

Backups: Improved Solutions

Replicate over multiple machines Incremental backups: Store only the changes compared to previous revision

◮ With file granularity ◮ With finer-grained (diff)

Many tools available:

◮ Standalone tools: rsync, rdiff-backup, . . . ◮ Versionned filesystems: VMS, Windows 2003+, cvsfs, . . . Matthieu Moy (Verimag) DVC 2007 < 5 / 43 >

slide-10
SLIDE 10

Prehistory History Linux Git Conclusion

Collaborative Development: The Old Good Time

Basic problems: Several persons working on the same set of files

1

“Hey, you’ve modified the same file as me, how do we merge?”,

2

“Your modifications are broken, your code doesn’t even compile. Fix your changes before sending it to me!”,

3

“Your bug fix here seems interesting, but I don’t want your other changes”.

Matthieu Moy (Verimag) DVC 2007 < 6 / 43 >

slide-11
SLIDE 11

Prehistory History Linux Git Conclusion

Collaborative Development: The Old Good Time

Basic problems: Several persons working on the same set of files

1

“Hey, you’ve modified the same file as me, how do we merge?”,

2

“Your modifications are broken, your code doesn’t even compile. Fix your changes before sending it to me!”,

3

“Your bug fix here seems interesting, but I don’t want your other changes”.

Historical solutions:

Matthieu Moy (Verimag) DVC 2007 < 6 / 43 >

slide-12
SLIDE 12

Prehistory History Linux Git Conclusion

Collaborative Development: The Old Good Time

Basic problems: Several persons working on the same set of files

1

“Hey, you’ve modified the same file as me, how do we merge?”,

2

“Your modifications are broken, your code doesn’t even compile. Fix your changes before sending it to me!”,

3

“Your bug fix here seems interesting, but I don’t want your other changes”.

Historical solutions:

◮ Never two person work at the same time. When one person stops

working, (s)he sends his/her work to the others. ⇒ Doesn’t scale up! Unsafe.

Matthieu Moy (Verimag) DVC 2007 < 6 / 43 >

slide-13
SLIDE 13

Prehistory History Linux Git Conclusion

Collaborative Development: The Old Good Time

Basic problems: Several persons working on the same set of files

1

“Hey, you’ve modified the same file as me, how do we merge?”,

2

“Your modifications are broken, your code doesn’t even compile. Fix your changes before sending it to me!”,

3

“Your bug fix here seems interesting, but I don’t want your other changes”.

Historical solutions:

◮ Never two person work at the same time. When one person stops

working, (s)he sends his/her work to the others. ⇒ Doesn’t scale up! Unsafe.

◮ People work on the same directory (same machine, NFS, . . . )

⇒ Painful because of (2) above.

Matthieu Moy (Verimag) DVC 2007 < 6 / 43 >

slide-14
SLIDE 14

Prehistory History Linux Git Conclusion

Collaborative Development: The Old Good Time

Basic problems: Several persons working on the same set of files

1

“Hey, you’ve modified the same file as me, how do we merge?”,

2

“Your modifications are broken, your code doesn’t even compile. Fix your changes before sending it to me!”,

3

“Your bug fix here seems interesting, but I don’t want your other changes”.

Historical solutions:

◮ Never two person work at the same time. When one person stops

working, (s)he sends his/her work to the others. ⇒ Doesn’t scale up! Unsafe.

◮ People work on the same directory (same machine, NFS, . . . )

⇒ Painful because of (2) above.

◮ People lock the file when working on it.

⇒ Hardly scales up!

Matthieu Moy (Verimag) DVC 2007 < 6 / 43 >

slide-15
SLIDE 15

Prehistory History Linux Git Conclusion

Collaborative Development: The Old Good Time

Basic problems: Several persons working on the same set of files

1

“Hey, you’ve modified the same file as me, how do we merge?”,

2

“Your modifications are broken, your code doesn’t even compile. Fix your changes before sending it to me!”,

3

“Your bug fix here seems interesting, but I don’t want your other changes”.

Historical solutions:

◮ Never two person work at the same time. When one person stops

working, (s)he sends his/her work to the others. ⇒ Doesn’t scale up! Unsafe.

◮ People work on the same directory (same machine, NFS, . . . )

⇒ Painful because of (2) above.

◮ People lock the file when working on it.

⇒ Hardly scales up!

◮ People work trying to avoid conflicts, and merge later. Matthieu Moy (Verimag) DVC 2007 < 6 / 43 >

slide-16
SLIDE 16

Prehistory History Linux Git Conclusion

Merging: Problem and Solution

My version #include <stdio.h> int main () { printf("Hello"); return EXIT_SUCCESS; } Your version #include <stdio.h> int main () { printf("Hello!\n"); return 0; }

Matthieu Moy (Verimag) DVC 2007 < 7 / 43 >

slide-17
SLIDE 17

Prehistory History Linux Git Conclusion

Merging: Problem and Solution

My version #include <stdio.h> int main () { printf("Hello"); return EXIT_SUCCESS; } Your version #include <stdio.h> int main () { printf("Hello!\n"); return 0; } Common ancestor #include <stdio.h> int main () { printf("Hello"); return 0; }

Matthieu Moy (Verimag) DVC 2007 < 7 / 43 >

slide-18
SLIDE 18

Prehistory History Linux Git Conclusion

Merging: Problem and Solution

My version #include <stdio.h> int main () { printf("Hello"); return EXIT_SUCCESS; } Your version #include <stdio.h> int main () { printf("Hello!\n"); return 0; } Common ancestor #include <stdio.h> int main () { printf("Hello"); return 0; }

Tools like diff3 or diff + patch can solve this Merging relies on history!

Matthieu Moy (Verimag) DVC 2007 < 7 / 43 >

slide-19
SLIDE 19

Prehistory History Linux Git Conclusion

Merging: Problem and Solution

My version #include <stdio.h> int main () { printf("Hello"); return EXIT_SUCCESS; } Your version #include <stdio.h> int main () { printf("Hello!\n"); return 0; } Common ancestor #include <stdio.h> int main () { printf("Hello"); return 0; }

Tools like diff3 or diff + patch can solve this Merging relies on history! Collaborative development linked to backups

Matthieu Moy (Verimag) DVC 2007 < 7 / 43 >

slide-20
SLIDE 20

Prehistory History Linux Git Conclusion

Merging

Space of possible revisions (arbitrarily represented in 2D)

Matthieu Moy (Verimag) DVC 2007 < 8 / 43 >

slide-21
SLIDE 21

Prehistory History Linux Git Conclusion

Merging

Space of possible revisions (arbitrarily represented in 2D) Mine Yours

Matthieu Moy (Verimag) DVC 2007 < 8 / 43 >

slide-22
SLIDE 22

Prehistory History Linux Git Conclusion

Merging

Space of possible revisions (arbitrarily represented in 2D) Mine Yours Ancestor

Matthieu Moy (Verimag) DVC 2007 < 8 / 43 >

slide-23
SLIDE 23

Prehistory History Linux Git Conclusion

Merging

Space of possible revisions (arbitrarily represented in 2D) Mine Yours Ancestor Merged revision

Matthieu Moy (Verimag) DVC 2007 < 8 / 43 >

slide-24
SLIDE 24

Prehistory History Linux Git Conclusion

Revision Control System: Basic Idea

Keep track of history:

◮ User makes modification and use commit to keep a snapshot of the

current state,

◮ Meta-data (user’s name, date, descriptive message,. . . ) recorded

together with the state of the project.

Use it for merging/collaborative development.

◮ Each user works on its own copy, ◮ User explicitly “takes” modifications from others when (s)he wants. Matthieu Moy (Verimag) DVC 2007 < 9 / 43 >

slide-25
SLIDE 25

Prehistory History Linux Git Conclusion

Revision Control System: Basic Idea

Keep track of history:

◮ User makes modification and use commit to keep a snapshot of the

current state,

◮ Meta-data (user’s name, date, descriptive message,. . . ) recorded

together with the state of the project.

Use it for merging/collaborative development.

◮ Each user works on its own copy, ◮ User explicitly “takes” modifications from others when (s)he wants.

Efficient storage (“delta-compression” ≈ incremental backups):

◮ At least at file level (git unpacked format), ◮ Usually store a concatenation of diffs or similar. Matthieu Moy (Verimag) DVC 2007 < 9 / 43 >

slide-26
SLIDE 26

Prehistory History Linux Git Conclusion

Revision Control System: Basic Idea

Keep track of history:

◮ User makes modification and use commit to keep a snapshot of the

current state,

◮ Meta-data (user’s name, date, descriptive message,. . . ) recorded

together with the state of the project.

Use it for merging/collaborative development.

◮ Each user works on its own copy, ◮ User explicitly “takes” modifications from others when (s)he wants.

Efficient storage (“delta-compression” ≈ incremental backups):

◮ At least at file level (git unpacked format), ◮ Usually store a concatenation of diffs or similar.

(Optional) notion of branch:

◮ Set of revisions recorded, but not visible in mainline, ◮ Can be merged into mainline when ready. Matthieu Moy (Verimag) DVC 2007 < 9 / 43 >

slide-27
SLIDE 27

Prehistory History Linux Git Conclusion

Outline

1

Motivations, Prehistory

2

History and Categories of Version Control Systems

3

Version Control for the Linux Kernel

4

Git: One Decentralized Revision Control System

5

Conclusion

Matthieu Moy (Verimag) DVC 2007 < 10 / 43 >

slide-28
SLIDE 28

Prehistory History Linux Git Conclusion

CVS: The Centralized Approach

Configuration:

◮ 1 repository (contains all about the history of the project) ◮ 1 working copy per user (contains only the files of the project)

Basic operations:

◮ checkout: get a new working copy ◮ update: update the working copy to include new revisions in the

repository

◮ commit: record a new revision in the repository Matthieu Moy (Verimag) DVC 2007 < 11 / 43 >

slide-29
SLIDE 29

Prehistory History Linux Git Conclusion

CVS: Example

Start working on a project: $ cvs checkout project $ cd project Work on it: $ vi foo.c # or whatever See if other users did something, and if so, get their modifications: $ cvs update Review local changes: $ cvs diff Record local changes in the repository (make it visible to others): $ cvs commit -m "Fixed incorrect Hello message"

Matthieu Moy (Verimag) DVC 2007 < 12 / 43 >

slide-30
SLIDE 30

Prehistory History Linux Git Conclusion

Commit/Update Approach

Space of possible revisions

Matthieu Moy (Verimag) DVC 2007 < 13 / 43 >

slide-31
SLIDE 31

Prehistory History Linux Git Conclusion

Commit/Update Approach

Space of possible revisions Existing revision

Matthieu Moy (Verimag) DVC 2007 < 13 / 43 >

slide-32
SLIDE 32

Prehistory History Linux Git Conclusion

Commit/Update Approach

Space of possible revisions Existing revision User works on a checkout

Matthieu Moy (Verimag) DVC 2007 < 13 / 43 >

slide-33
SLIDE 33

Prehistory History Linux Git Conclusion

Commit/Update Approach

Space of possible revisions Existing revision User works on a checkout New upstream revisions

Matthieu Moy (Verimag) DVC 2007 < 13 / 43 >

slide-34
SLIDE 34

Prehistory History Linux Git Conclusion

Commit/Update Approach

Space of possible revisions Existing revision User works on a checkout New upstream revisions

Matthieu Moy (Verimag) DVC 2007 < 13 / 43 >

slide-35
SLIDE 35

Prehistory History Linux Git Conclusion

Commit/Update Approach

Space of possible revisions Existing revision User works on a checkout New upstream revisions

Matthieu Moy (Verimag) DVC 2007 < 13 / 43 >

slide-36
SLIDE 36

Prehistory History Linux Git Conclusion

Commit/Update Approach

Space of possible revisions Existing revision User works on a checkout New upstream revisions

Matthieu Moy (Verimag) DVC 2007 < 13 / 43 >

slide-37
SLIDE 37

Prehistory History Linux Git Conclusion

Commit/Update Approach

Space of possible revisions Existing revision User works on a checkout New upstream revisions User runs "update"

Matthieu Moy (Verimag) DVC 2007 < 13 / 43 >

slide-38
SLIDE 38

Prehistory History Linux Git Conclusion

Commit/Update Approach

Space of possible revisions Existing revision New upstream revisions User runs "update"

Matthieu Moy (Verimag) DVC 2007 < 13 / 43 >

slide-39
SLIDE 39

Prehistory History Linux Git Conclusion

Commit/Update Approach

Space of possible revisions Existing revision New upstream revisions User runs "update" "commit" creates new revision

Matthieu Moy (Verimag) DVC 2007 < 13 / 43 >

slide-40
SLIDE 40

Prehistory History Linux Git Conclusion

Commit/Update Approach

Space of possible revisions Existing revision New upstream revisions User runs "update" "commit" creates new revision

And so on ... !

Matthieu Moy (Verimag) DVC 2007 < 13 / 43 >

slide-41
SLIDE 41

Prehistory History Linux Git Conclusion

Conflicts

When several users change the same line of code concurrently, Impossible for the tool to guess which version to take, ⇒ CVS leaves both versions with explicit markers, user resolves manually. Merge tools (Emacs’s smerge-mode, . . . ) can help.

Matthieu Moy (Verimag) DVC 2007 < 14 / 43 >

slide-42
SLIDE 42

Prehistory History Linux Git Conclusion

Conflicts: an Example

Someone added “\n”, someone else added “!”: #include <stdio.h> int main () { <<<<<<< hello.c printf("Hello\n"); ======= printf("Hello!"); >>>>>>> 1.6 return EXIT_SUCCESS; }

Matthieu Moy (Verimag) DVC 2007 < 15 / 43 >

slide-43
SLIDE 43

Prehistory History Linux Git Conclusion

CVS: Obvious Limitations

File-based system. No easy way to get back to a consistant old revision. No management of rename (remove + add) Bad performances

Matthieu Moy (Verimag) DVC 2007 < 16 / 43 >

slide-44
SLIDE 44

Prehistory History Linux Git Conclusion

Subversion: A Replacement for CVS

Idea of subversion: drop-in replacement for CVS (could have been “CVS, version 2”).

◮ Atomic, tree-wide commits (commit is either successful or unsuccessful,

but not half),

◮ Rename management, ◮ Optimized performances, some operations available offline.

Fix the obvious limitation, but no major change/innovation

Matthieu Moy (Verimag) DVC 2007 < 17 / 43 >

slide-45
SLIDE 45

Prehistory History Linux Git Conclusion

Subversion: A Replacement for CVS

Idea of subversion: drop-in replacement for CVS (could have been “CVS, version 2”).

◮ Atomic, tree-wide commits (commit is either successful or unsuccessful,

but not half),

◮ Rename management, ◮ Optimized performances, some operations available offline.

Fix the obvious limitation, but no major change/innovation from Subversion’s FAQ: We aren’t attempting to break new ground in SCM systems, nor are we attempting to imitate all the best features of every SCM system out there. We’re trying to replace CVS. [...]

Matthieu Moy (Verimag) DVC 2007 < 17 / 43 >

slide-46
SLIDE 46

Prehistory History Linux Git Conclusion

Remaining Limitations

Weak support for merging, Most operations can not be performed offline, No private branches Permission management:

◮ Allowing anyone on earth to commit compromises the security, ◮ Denying someone permission to commit means this user can not use

most of the features

◮ Constraint acceptable for private project, but painful for Free Software

in particular.

Matthieu Moy (Verimag) DVC 2007 < 18 / 43 >

slide-47
SLIDE 47

Prehistory History Linux Git Conclusion

Decentralized Revision Control Systems

Idea: not just 1 central repository. Each user has his own repository. By default, operations (including commit) are done on the user’s private branch. Users publish their repository, and request a merge.

Matthieu Moy (Verimag) DVC 2007 < 19 / 43 >

slide-48
SLIDE 48

Prehistory History Linux Git Conclusion

Outline

1

Motivations, Prehistory

2

History and Categories of Version Control Systems

3

Version Control for the Linux Kernel

4

Git: One Decentralized Revision Control System

5

Conclusion

Matthieu Moy (Verimag) DVC 2007 < 20 / 43 >

slide-49
SLIDE 49

Prehistory History Linux Git Conclusion

Linux: A Project With Huge Needs in Version Control

Not the biggest Open-Source project, but probably the most active, ≈ 10Mb of patch per month, ≈ 20,000 files, 280Mb of sources. Many branches:

◮ Short life: work on a feature in a branch, request merge when ready. ◮ Long life: things that are unlikely to get into the official kernel before

some time (grsecurity, reiserfs4, SELinux in the past, . . . )

◮ Test, debug: a modification goes through several branches, is tested

there, before getting into mainline

◮ Distributor: Most distributions maintain a modified version of Linux

⇒ Centralized revision control is not manageable.

Matthieu Moy (Verimag) DVC 2007 < 21 / 43 >

slide-50
SLIDE 50

Prehistory History Linux Git Conclusion

A bit of history

1991: Linus Torvalds starts writing Linux, using mostly CVS, 2002: Linux adopts BitKeeper, a proprietary decentralized version control system (available free of cost for Linux), 2002-2005: Flamewars against BitKeeper, some Free Software alternatives appear (GNU Arch, Darcs, Monotone). None are good enough technically.

Matthieu Moy (Verimag) DVC 2007 < 22 / 43 >

slide-51
SLIDE 51

Prehistory History Linux Git Conclusion

A bit of history

1991: Linus Torvalds starts writing Linux, using mostly CVS, 2002: Linux adopts BitKeeper, a proprietary decentralized version control system (available free of cost for Linux), 2002-2005: Flamewars against BitKeeper, some Free Software alternatives appear (GNU Arch, Darcs, Monotone). None are good enough technically. 2005: BitKeeper’s free of cost license revoked. Linux has to migrate. 2005: Unsatisfied with the alternatives, Linus decides to start his

  • wn project, git.

Matthieu Moy (Verimag) DVC 2007 < 22 / 43 >

slide-52
SLIDE 52

Prehistory History Linux Git Conclusion

A bit of history

1991: Linus Torvalds starts writing Linux, using mostly CVS, 2002: Linux adopts BitKeeper, a proprietary decentralized version control system (available free of cost for Linux), 2002-2005: Flamewars against BitKeeper, some Free Software alternatives appear (GNU Arch, Darcs, Monotone). None are good enough technically. 2005: BitKeeper’s free of cost license revoked. Linux has to migrate. 2005: Unsatisfied with the alternatives, Linus decides to start his

  • wn project, git.

2007: Many young, but good projects for decentralized revision control: Git, Mercurial, Bazaar, Monotone, Darcs, . . . 200?: Most likely, several projects will continue to compete, but I guess only 2 or 3 of the best will be widely adopted.

Matthieu Moy (Verimag) DVC 2007 < 22 / 43 >

slide-53
SLIDE 53

Prehistory History Linux Git Conclusion

Outline

1

Motivations, Prehistory

2

History and Categories of Version Control Systems

3

Version Control for the Linux Kernel

4

Git: One Decentralized Revision Control System

5

Conclusion

Matthieu Moy (Verimag) DVC 2007 < 23 / 43 >

slide-54
SLIDE 54

Prehistory History Linux Git Conclusion

Git Concepts

Revision: State of a project at a point in time, with meta-information, Repository: Set of revisions, with ancestry information, Branch: Succession of revisions, Working tree: The project itself (set of files, directories. . . ).

Matthieu Moy (Verimag) DVC 2007 < 24 / 43 >

slide-55
SLIDE 55

Prehistory History Linux Git Conclusion

Git basic idea

Git manages a set of objects (revision, files, directories, ...), Each object is identified by its sha1 sum (e.g. d188b7e3a58ce5a6a437c01e7095e79cba550d52), Objects can point to each other.

Matthieu Moy (Verimag) DVC 2007 < 25 / 43 >

slide-56
SLIDE 56

Prehistory History Linux Git Conclusion

Starting a Project

Create a new project: $ mkdir project (or just use an existing one) $ cd project $ git init This creates a repository and a working tree in the same place. Try “ls .git/” to see what happened.

Matthieu Moy (Verimag) DVC 2007 < 26 / 43 >

slide-57
SLIDE 57

Prehistory History Linux Git Conclusion

Create the First Revision

Add files (git won’t touch the files unless you explicitly add them): $ git add .

  • r individually

$ git add file1; git add file2 Commit (record new revision): $ git commit -m "descriptive message" (if you don’t provide -m, an editor will be opened to let you type your message) Unlike most version control systems, git ask you to “git add” files when you change them. Surprising, but indeed powerful.

Matthieu Moy (Verimag) DVC 2007 < 27 / 43 >

slide-58
SLIDE 58

Prehistory History Linux Git Conclusion

Look at Your Own Changes

Short summary: git status

$ git status # Changed but not updated: # (use "git add <file>..." to update what will be committed) # # modified: bar.c # # Untracked files: # (use "git add <file>..." to include in what will be committed) # # foo.c

Matthieu Moy (Verimag) DVC 2007 < 28 / 43 >

slide-59
SLIDE 59

Prehistory History Linux Git Conclusion

Look at Your Own Changes

Short summary: git status Complete diff: git diff

$ git diff HEAD diff --git a/foo.c b/foo.c index d9bd708..a026613 100644

  • -- a/foo.c

+++ b/foo.c @@ -1,5 +1,5 @@ #include <stdio.h> int main() {

  • printf ("hello");

+ printf ("hello\n"); }

Matthieu Moy (Verimag) DVC 2007 < 28 / 43 >

slide-60
SLIDE 60

Prehistory History Linux Git Conclusion

Look at the History

See the past revisions:

$ git log commit 1d0ddc98025de7b159ac319a6e3d691fe5cf4c03 Author: Matthieu Moy <Matthieu.Moy@imag.fr> Date: Tue Oct 9 15:35:39 2007 +0200 Fixed a bug commit bf45d2100fe662b2afb8e48eb40d4bf5a7dbc2fe Author: Matthieu Moy <Matthieu.Moy@imag.fr> Date: Tue Oct 9 15:35:24 2007 +0200 initial revision

Matthieu Moy (Verimag) DVC 2007 < 29 / 43 >

slide-61
SLIDE 61

Prehistory History Linux Git Conclusion

Publish your repository

Up to now, your repository is just on your disk, no one else sees it, Publish you branch: $ git push ssh://some-host.com/project-upstream (git needs to be installed on the remote host, but no daemon needed) Other people can now clone it: $ git clone http://some-host.com/project-upstream (assuming the sftp location and http location are the same on some-host.com).

Matthieu Moy (Verimag) DVC 2007 < 30 / 43 >

slide-62
SLIDE 62

Prehistory History Linux Git Conclusion

Working on an Existing Project

Clone the remote repository: $ git clone http://some-host.com/project $ cd project

Matthieu Moy (Verimag) DVC 2007 < 31 / 43 >

slide-63
SLIDE 63

Prehistory History Linux Git Conclusion

Working on an Existing Project

Clone the remote repository: $ git clone http://some-host.com/project $ cd project Work on it! Commit your changes: $ git commit -m "implemented something awesome"

Matthieu Moy (Verimag) DVC 2007 < 31 / 43 >

slide-64
SLIDE 64

Prehistory History Linux Git Conclusion

Working on an Existing Project

Clone the remote repository: $ git clone http://some-host.com/project $ cd project Work on it! Commit your changes: $ git commit -m "implemented something awesome" Publish it and request a merge: $ git push ssh://another-host.com/your/project $ mail -s "please, merge ..."

Matthieu Moy (Verimag) DVC 2007 < 31 / 43 >

slide-65
SLIDE 65

Prehistory History Linux Git Conclusion

Merging

Two use cases:

◮ As a contributor, you started working on a feature in your own

repository, but you want to follow upstream development.

◮ Your feature is completed, upstream wants to merge it.

Symetry in both use-cases, Successive merge possible, Git keeps track of merge history. It knows what you miss, and what has already been merged.

Matthieu Moy (Verimag) DVC 2007 < 32 / 43 >

slide-66
SLIDE 66

Prehistory History Linux Git Conclusion

Merging

Merge the changes into the local repository: $ git pull ../bar/

Matthieu Moy (Verimag) DVC 2007 < 33 / 43 >

slide-67
SLIDE 67

Prehistory History Linux Git Conclusion

Merging

Merge the changes into the local repository: $ git pull ../bar/ Merge Commit: Unless you’re merging a branch which you are a direct ancestor of, git will create a new commit, corresponding to the merge.

Matthieu Moy (Verimag) DVC 2007 < 33 / 43 >

slide-68
SLIDE 68

Prehistory History Linux Git Conclusion

Merging

Space of possible revisions

Matthieu Moy (Verimag) DVC 2007 < 34 / 43 >

slide-69
SLIDE 69

Prehistory History Linux Git Conclusion

Merging

Space of possible revisions Existing revision

Matthieu Moy (Verimag) DVC 2007 < 34 / 43 >

slide-70
SLIDE 70

Prehistory History Linux Git Conclusion

Merging

Space of possible revisions Existing revision User works on a local branch

Matthieu Moy (Verimag) DVC 2007 < 34 / 43 >

slide-71
SLIDE 71

Prehistory History Linux Git Conclusion

Merging

Space of possible revisions Existing revision User works on a local branch local commit

Matthieu Moy (Verimag) DVC 2007 < 34 / 43 >

slide-72
SLIDE 72

Prehistory History Linux Git Conclusion

Merging

Space of possible revisions Existing revision User works on a local branch local commit New upstream revisions

Matthieu Moy (Verimag) DVC 2007 < 34 / 43 >

slide-73
SLIDE 73

Prehistory History Linux Git Conclusion

Merging

Space of possible revisions Existing revision User works on a local branch local commit New upstream revisions

Matthieu Moy (Verimag) DVC 2007 < 34 / 43 >

slide-74
SLIDE 74

Prehistory History Linux Git Conclusion

Merging

Space of possible revisions Existing revision User works on a local branch local commit New upstream revisions

Matthieu Moy (Verimag) DVC 2007 < 34 / 43 >

slide-75
SLIDE 75

Prehistory History Linux Git Conclusion

Merging

Space of possible revisions Existing revision User works on a local branch local commit New upstream revisions

Matthieu Moy (Verimag) DVC 2007 < 34 / 43 >

slide-76
SLIDE 76

Prehistory History Linux Git Conclusion

Merging

Space of possible revisions Existing revision User works on a local branch local commit New upstream revisions merge runs upstream

Matthieu Moy (Verimag) DVC 2007 < 34 / 43 >

slide-77
SLIDE 77

Prehistory History Linux Git Conclusion

Merging

Space of possible revisions Existing revision User works on a local branch local commit New upstream revisions merge runs upstream

Matthieu Moy (Verimag) DVC 2007 < 34 / 43 >

slide-78
SLIDE 78

Prehistory History Linux Git Conclusion

Merging

Space of possible revisions Existing revision User works on a local branch local commit New upstream revisions merge runs upstream new revision created

Matthieu Moy (Verimag) DVC 2007 < 34 / 43 >

slide-79
SLIDE 79

Prehistory History Linux Git Conclusion

Merging

Space of possible revisions Existing revision User works on a local branch local commit New upstream revisions merge runs upstream new revision created

And so on ... !

Matthieu Moy (Verimag) DVC 2007 < 34 / 43 >

slide-80
SLIDE 80

Prehistory History Linux Git Conclusion

Merging

Space of possible revisions Existing revision User works on a local branch local commit New upstream revisions merge runs upstream new revision created

And so on ... !

Resulting revision history is a DAG

Matthieu Moy (Verimag) DVC 2007 < 34 / 43 >

slide-81
SLIDE 81

Prehistory History Linux Git Conclusion

Other Features of Interest

Git index: A staging area to prepare your commits. Probably the most powerful way to make partial commits. Tags: Give a name to a revision (e.g. “release-1.0”) Local branches: Multiple branches within the same repository, Pack files: The default storage format for git is disk-inefficient. Run “git gc” occasionally, and you’ll get the most compact format of the VCS I know about. Subversion interface: git-svn allows you to use git on a subversion repository. Git daemon: serve Git repository much faster than plain HTTP.

Matthieu Moy (Verimag) DVC 2007 < 35 / 43 >

slide-82
SLIDE 82

Prehistory History Linux Git Conclusion

Outline

1

Motivations, Prehistory

2

History and Categories of Version Control Systems

3

Version Control for the Linux Kernel

4

Git: One Decentralized Revision Control System

5

Conclusion

Matthieu Moy (Verimag) DVC 2007 < 36 / 43 >

slide-83
SLIDE 83

Prehistory History Linux Git Conclusion

Benefit of Version Control

Working alone:

◮ Possibility to revert to a previous revision, ◮ Makes it easy to review your own code (before committing), ◮ Synchronization of multiple machines.

Collaborative development:

◮ One can work without disturbing others, ◮ Merge is automated. Matthieu Moy (Verimag) DVC 2007 < 37 / 43 >

slide-84
SLIDE 84

Prehistory History Linux Git Conclusion

Benefit of Version Control

Working alone:

◮ Possibility to revert to a previous revision, ◮ Makes it easy to review your own code (before committing), ◮ Synchronization of multiple machines.

Collaborative development:

◮ One can work without disturbing others, ◮ Merge is automated.

“Text editing without version control is like sky diving without a parachute!”

Matthieu Moy (Verimag) DVC 2007 < 37 / 43 >

slide-85
SLIDE 85

Prehistory History Linux Git Conclusion

Benefit of Decentralized Version Control

Easy branch/merge, Simplifies permission management (no need to give any permission to other users), Disconnected operation (useful for laptop users in particular). Private branches.

Matthieu Moy (Verimag) DVC 2007 < 38 / 43 >

slide-86
SLIDE 86

Prehistory History Linux Git Conclusion

Other Decentralized Version Control Systems

Monotone: A clever system based on hashes (SHA1). Inspired git a lot. http://venge.net/monotone/ Bazaar: Designed for ease of use and flexibility. Used and developed by Canonical (Ubuntu), http://bazaar-vcs.org/ Mercurial: Close in concepts and performance to git. Written in python, with a plugin system. http://www.selenic.com/mercurial/ Darcs: Based on a powerful patch theory. Was the first system to have a really simple user-interface. http://abridgegame.org/darcs/ SVK: Distributed Version Control built on top of Subversion. http://svk.bestpractical.com/

Matthieu Moy (Verimag) DVC 2007 < 39 / 43 >

slide-87
SLIDE 87

Prehistory History Linux Git Conclusion

Emacs Users

[ Warning: Self advertisement ] Most version control systems have an Emacs integration. Check out DVC: http://download.gna.org/dvc/

Matthieu Moy (Verimag) DVC 2007 < 40 / 43 >

slide-88
SLIDE 88

Prehistory History Linux Git Conclusion

Version Control and Backups

Version Control is a good complement for backups But your repository should be backed-up/replicated ! (many users lost their data and their revision history at the same time with a disk crash) Usually:

◮ Version Control = User side (manual creation of project, manual add

  • f source files, manual commits, . . . )

◮ Backup = System Administrator side (cron job, backing up everything) Matthieu Moy (Verimag) DVC 2007 < 41 / 43 >

slide-89
SLIDE 89

Prehistory History Linux Git Conclusion

Last Word on Backups

Don’t trust your hard disk, Don’t trust a CD (too short life), Don’t trust yourself, Don’t trust Anything! REPLICATE!!!

◮ Multiple machines for normal work ◮ Multiple sites for important work (are you ready to loose you thesis if

your house or lab burns?)

Matthieu Moy (Verimag) DVC 2007 < 42 / 43 >

slide-90
SLIDE 90

Prehistory History Linux Git Conclusion

Learn More

Git: http://git.or.cz/ Git Tutorial: http://www.kernel.org/pub/software/scm/git/docs/tutorial.html Version Control: http://en.wikipedia.org/wiki/Revision control This presentation: http://www-verimag.imag.fr/∼moy/slides/git/

Matthieu Moy (Verimag) DVC 2007 < 43 / 43 >