git vs subversion: ¿cuando elegir uno u otro?

36
GIT VS. SVN Which one should we use and when? http://www.paradigmatecnologico.com @paradigmate http://marianonavas.me @marianongdev

Upload: paradigma-tecnologico

Post on 10-May-2015

1.800 views

Category:

Technology


3 download

DESCRIPTION

Javahispano y Paradigma Tecnológico organizan un un seminario sobre una comparativa de sistemas de versionado: Subversion vs. Git. Seminario presentado por Mariano Navas el 29 de Mayo de 2013 en UPM. Dentro del mundo de los sistemas de control de versiones tenemos dos grandes grupos: los centralizados y los distribuidos. Subversion es en buena medida el representante más notable en el grupo de los centralizados. En los distribuidos git se está imponiendo como la tendencia. Más información sobre el seminario: http://www.paradigmatecnologico.com/seminarios/git-vs-subversion-cuando-utilizar-uno-u-otro/ Vídeo youtube: https://www.youtube.com/watch?v=nR5L3sJRp_c ¿Quieres saber más? http://www.paradigmatecnologico.com

TRANSCRIPT

Page 1: Git vs Subversion: ¿Cuando elegir uno u otro?

GIT VS. SVN Which one should we use and when?

http://www.paradigmatecnologico.com

@paradigmate

http://marianonavas.me

@marianongdev

Page 2: Git vs Subversion: ¿Cuando elegir uno u otro?

What is a CVS for?

• Allow team work together and collaborate

• Have some kind of time machine in our code

• Allow CI

Page 3: Git vs Subversion: ¿Cuando elegir uno u otro?

Approaches (architectural models)

• Local

• Rcs (Mac OS Developer Tools)

• Centralized

• Subversion

• CVS

• Perforce

• Distributed

• Git

• Mercurial

Page 4: Git vs Subversion: ¿Cuando elegir uno u otro?

Approaches (architectural models)

• Local

• Rcs (Mac OS Developer Tools)

• Centralized

• Subversion

• CVS

• Perforce

• Distributed

• Git

• Mercurial

Page 5: Git vs Subversion: ¿Cuando elegir uno u otro?

Very good resource

Page 6: Git vs Subversion: ¿Cuando elegir uno u otro?

Centralized CVS

Page 7: Git vs Subversion: ¿Cuando elegir uno u otro?

Distributed CVS

Page 8: Git vs Subversion: ¿Cuando elegir uno u otro?

Centralized

• Pros

• Looks simple

• We know it well; we've been using it for a long time

• Good mainstream IDEs integration

• It works

• Cons

• We cannot commit offline (well, we can, but …)

• We cannot integrate in our development toolset more than one

repository

• Dificult to collaborate if team is large (i.e. open source projects)

• We are encouraged to avoid branches by the system.

Page 9: Git vs Subversion: ¿Cuando elegir uno u otro?

Distributed

• Pros

• Allow offline work

• Easy collaboration model

• Can link as many repositories as we might need

• Almost every operation is local

• Complete copy of the repository in each machine

• Easy installation on server, and plenty of hosting services (free and

paid)

• Cons

• More complex workflow (or not?)

• Difficult to learn

• ?????

Page 10: Git vs Subversion: ¿Cuando elegir uno u otro?

Internal representation of data; SVN

Page 11: Git vs Subversion: ¿Cuando elegir uno u otro?

Branching in SVN

Page 12: Git vs Subversion: ¿Cuando elegir uno u otro?

Branching in SVN

Quotes taken from official svn website

• "For projects that have a large number of contributors, it's common for most people to have working copies of the trunk. Whenever someone needs to make a long-running change that is likely to disrupt the trunk, a standard procedure is to create a private branch and commit changes there until all the work is complete"

• "The bad news is that it's very easy to drift too far apart (...) it may be near-impossible to merge your changes back into the trunk without a huge number of conflicts"

• "Subversion gives you the ability to selectively “copy” changes between branches. And when you're completely finished with your branch, your entire set of branch changes can be copied back into the trunk. In Subversion terminology, the general act of replicating changes from one branch to another is called merging, and it is performed using various invocations of the svn merge subcommand”

Page 13: Git vs Subversion: ¿Cuando elegir uno u otro?

Branching in SVN I (typical workflow)

• Checkout from trunk.

• Add a new file to working copy

• Check status (svn st).

• Track new file in svn (svn add).

• Commit the new file (svn ci).

• Modify the file, and check status again (svn st).

• Commit the new change.

• Modify again and let it remain modified.

Page 14: Git vs Subversion: ¿Cuando elegir uno u otro?

Branching in SVN II (branch & merge)

• Svn copy at server level.

• Check current working copy remote path (svn info).

• Switch to new location (svn switch [remote] .)

• Check remote again (svn info).

• Commit some change to the branch.

• Switch again to trunk.

• Merge trunk with [myNewBranch] (svn merge [source@rev] .). Note that we do it with the working copy first to merge conflicts locally.

• Commit to finish merge (we’ve done it locally in the previous step).

• Again with a non-conflicting change in the same file.

• Again with a conflicting change.

Page 15: Git vs Subversion: ¿Cuando elegir uno u otro?

Internal representation of data; svn

• Repository: the main idea

• Working copy

• Revisions, which are deltas of a base state

• The server has to workout deltas to resolve the concrete

state of a revision (commit)

• Each revision gets a unique (secuential) id. This is

possible because it's centralized

• Branches: are light copies of complete working trees

• Summary: branch=copy.

Page 16: Git vs Subversion: ¿Cuando elegir uno u otro?

Drawbacks I: only one remote

Page 17: Git vs Subversion: ¿Cuando elegir uno u otro?

Drawbacks II: branch & merge sucks

• Recall branch & merge procedure:

• Copy trunk in branch directory in remote server

• Checkout (or switch) locally.

• Inspect revision we want to merge with, if not last.

• Call svn merge.

• Resolve conflicts (if any).

• Commit the whole thing.

• In practice we feel encouraged to not create branches

(bad, bad, bad …).

Page 18: Git vs Subversion: ¿Cuando elegir uno u otro?

Drawback III: cleanliness

• What if I want to merge my branch just to get up to date

with our trunk, but I don’t want to make it public yet

(incomplete feature or just playing around)?

Page 19: Git vs Subversion: ¿Cuando elegir uno u otro?

Drawback IV: privacy

• Do I have to publish my code to a remote/public server to

have version control? What if I’m doing some experiments

I don’t want other people to see, or I just don’t want to

mess up our central repository with something I don’t

know if it’s going to work?

Page 20: Git vs Subversion: ¿Cuando elegir uno u otro?

Internal representation of data; git

Page 21: Git vs Subversion: ¿Cuando elegir uno u otro?

Git – file status lifecycle

Page 23: Git vs Subversion: ¿Cuando elegir uno u otro?

Branching in git

Page 24: Git vs Subversion: ¿Cuando elegir uno u otro?

Deeper insight in git DAG internal

structure

Page 25: Git vs Subversion: ¿Cuando elegir uno u otro?

Another view of git objects I

Page 26: Git vs Subversion: ¿Cuando elegir uno u otro?

Another view of git objects II

Page 27: Git vs Subversion: ¿Cuando elegir uno u otro?

Another view of git objects III

Page 28: Git vs Subversion: ¿Cuando elegir uno u otro?

Details on how git stores that in disk

• http://git-scm.com/book/en/Git-Internals-Git-Objects

Page 29: Git vs Subversion: ¿Cuando elegir uno u otro?

Branches and HEAD

Page 30: Git vs Subversion: ¿Cuando elegir uno u otro?

More on git internal representation of data

• http://eagain.net/articles/git-for-computer-scientists/

• http://en.wikipedia.org/wiki/Directed_acyclic_graph

• Due to its distributed nature unique ids for commits are

generated as SHA-1 digest to ensure unicity

• Explanation

• Snapshots, not deltas

• Commits: blobs

• Branches: references to commits

• Repeat: branch = pointer

• Current branch: HEAD pointer

• Detached heads: careful

Page 31: Git vs Subversion: ¿Cuando elegir uno u otro?

SVN branch & merge summary

• SVN has no branch concept. It's just another working

copy with a common history

• We can only merge two branches at a time

• SVN allow you to merge even not at all related trees

(error prone)

• Refactor and moving things around; svn doesn't manage

this kind of merges very well

• Only allows interaction one repository at a time.

Page 32: Git vs Subversion: ¿Cuando elegir uno u otro?

Git branch & merge summary

• It’s trivial to create a new branch from any point.

• Git prevents us from deleting unmerged branches.

• We can clean up obsolete branches keeping commits.

• We can move a branch around (recreate it from any

starting point).

• We can merge more than one branch at a time (3 or even

more!!!).

• Git understands moved and renamed files.

• This model encourage best practices: branch-per-feature,

local branches for testing and experiments, git-flow …

Page 33: Git vs Subversion: ¿Cuando elegir uno u otro?

Git allow us to manage branching well

Page 34: Git vs Subversion: ¿Cuando elegir uno u otro?

Git integration with SVN

Page 36: Git vs Subversion: ¿Cuando elegir uno u otro?

Wich CVS should I choose and when?