1. Working with Git distributed
revision control system
Jordi Mas – jmas@softcatala.org, @jordimash
Barcelona Developers Conference 2011
2. Index
- Introduction to Git
- Key concepts
- Branching
- The software
- Further reading
- On-hands work
3. What, Where, When, Why & Who
● Git is an open source DVCS (Distributed Version Control System)
● Comes from the needs of the kernel.org community
● Started in 2005 by Linus Torvalds, continued by Junio Hamano and +
● “...Distributed version control is … possibly the biggest advance in
software development technology in the [past] ten years." Joel
Spolsky *
● Other popular open source DVCS
Bazaar, Mercurial
* http://joelonsoftware.com/items/2010/03/17.html
4. Git - Features
● Distributed development ● Supports HTTP, FTP, rsync, or a
Git protocol (over ssh too).
● Fast as a shark
● Can act as a SVN/CVS server,
● Great support for branches transparent to legacy users
● Secure and consistent ● Pre / post hooks
● Toolkit design (Aka API)
● Multi-platform (Linux, Mac &
Windows)
5. Community
Hundreds
● Dozens of large open source projects (GNOME, Mono, KDE,
Kernel.org, Android, github hosting, etc) and corporate users using it
every day
● Good books from Apress, O'Reilly and on-line
● Community documentation
● Forums, mailing lists, weblogs, irc
6. Index
- Introduction to Git
- Key concepts
- Branching
- The software
- Further reading
- On-hands work
7. DVCS
● Server based (SVN, etc)
You have the lastest version of the repo
Depends always on a sever (commit, blame, etc)
Revisions numbers are tied to a repository
● Git
Every client has a full copy of the repository
Can work off-line
Revisions numbers are SHA-1 based on content
8. Staging area or index
● An intermediate local area that you can setup how your commit will
look like before you commit it. Like a temporary local branch.
Allows precise control of what your commit is going to look like
Usefull for single commits with many changes & files
● You can skip it by using git commit -a and work directly on the
repository
9. Index
- Introduction to Git
- Key concepts
- Branching
- The software
- Further reading
- On-hands work
10. Branches – diverging branch
● A branch uses 40 bytes since it is just a pointer (compare this to
the copy approach of SVN)
● A experiment branch with a single commit and master with a
different commit
11. Branches – 3 way merging
Three-way merge between the two latest branch snapshots (C3 and
C4) and the most recent common ancestor of the two (C2), creating a
new snapshot (and commit)
12. Branches – rebasing
Uses the common ancestor of the two branches getting the diff
introduced by each commit of the branch you’re on, saving those diffs
to temporary files, resetting the current branch to the same commit as
the branch you are rebasing onto, and finally applying each change in
turn.
13. Index
- Introduction to Git
- Key concepts
- Branching
- The software
- Further reading
- On-hands work