SlideShare une entreprise Scribd logo
1  sur  52
Git
Reuven M. Lerner • reuven@lerner.co.il
       Open Israel Conference
           June 30th, 2011
Who am I?
• Web developer, software architect,
  consultant, lecturer/trainer
• Linux Journal columnist since 1996
• Mostly Ruby on Rails + PostgreSQL, but
  also Python, PHP, jQuery, and lots more...
• Git user (and enthusiast) since 2008
What is
version control?
Time machine

• Return to any point in
  a project’s history
• Find out how files,
  folders have changed
• Learn which user
  made which changes
Backup

• Never fear that you’ve
  deleted a file — just
  rewind the history
• Everything is recorded,
  can be undone
Maintenance tool

• “Tag” releases
• Who is to blame for a particular bug?
• When did we introduce a particular
  problem?
• Deploy specific versions on specific servers
Scratchpad

• Try out new ideas
• Experiment with alternative techniques
• Upgrade a library
• Refactor without affecting the “live” code
  base
Collaboration tool
• Work without fear of
  “stomping” on
  someone else’s code
• Identify conflicts
  between what
  developers wrote
• Mix and match teams
  for projects
Version control is great
• If you’re a programmer and not using
  version control, you’re really missing out
 • It’s also good for non-programs, such as
    configuration files
• If you’re a CTO/team leader/VP R&D and
  your people aren’t using version control,
  you’re inviting disaster
What do people use?
• RCS (ancient history)
• CVS (should be ancient history)
• Subversion (“a better CVS”)
• SourceSafe
• Perforce
• lots of other systems
Problems with these
• Work requires a server connection
 • (You can work, but not commit.)
• Branching and merging is painful and slow
 • So no one does it!
• Enforces a particular workflow
• More code, more developers — slower VC
Distributed version
         control
• Distributed: Everyone is their own server!
• Everyone has a complete commit history
 • No single point of failure
• Commit whenever you want (i.e., often)
• Merge when two repositories connect
Git
• Linus needed a VCS... so he wrote one!
 • Fast
 • Accurate
 • Distributed
 • Massively scalable
 • Super flexible
Open-source Git users
• Linux kernel
• PostgreSQL
• Ruby language
• Ruby on Rails
• Perl language
• among many, many others
Give me details!


• What does Git do that others don’t?
• Why do I claim that Git has changed my
  life?
Branching & merging
• Branching and merging is both easy and fast
  in Git
• I often branch and merge several times in a
  given day
  • When I used SVN, I would do everything
    in my power to avoid branching, because
    merges were long and difficult
Branching & merging
• Create a branch:
 git checkout -b new-branch

• Merge commits from other-branch
 git merge other-branch

• Yes, it’s really that easy.
• You don’t even have to change directories!
Easy branching
   changes everything!
• Every new feature goes in a branch
• Merging becomes easy, fast, and natural
• Side projects are stored, not kept out of
  version control for fear of “contamination”
• Commit, commit, commit all of the time, in
  an appropriate branch — never lose work!
Local repository
         is great
• Work without a network connection
• Commits, merges, and switching branches
  are nearly instantaneous
• Reports and logs are super-fast
 • “Show me all files modified on Tuesday of
    last week” produces immediate resultss
Create a repository!
/tmp $ cd myapp
/tmp/myapp $ git init
Initialized empty Git repository in /private/tmp/myapp/.git/
master ✗ /tmp/myapp $ git add .
master ✗ /tmp/myapp $ git commit -a -m 'Initial commit'
[master (root-commit) 030c6b6] Initial commit
 1 files changed, 1 insertions(+), 0 deletions(-)
 create mode 100644 foo
Initial commit


master ✔ /tmp/myapp $
Create a repository!
/tmp $ cd myapp
/tmp/myapp $ git init
Initialized empty Git repository in /private/tmp/myapp/.git/
master ✗ /tmp/myapp $ git add .
master ✗ /tmp/myapp $ git commit -a -m 'Initial commit'
[master (root-commit) 030c6b6] Initial commit
 1 files changed, 1 insertions(+), 0 deletions(-)
 create mode 100644 foo
Initial commit


master ✔ /tmp/myapp $
Create a repository!
/tmp $ cd myapp
/tmp/myapp $ git init
Initialized empty Git repository in /private/tmp/myapp/.git/
master ✗ /tmp/myapp $ git add .
master ✗ /tmp/myapp $ git commit -a -m 'Initial commit'
[master (root-commit) 030c6b6] Initial commit
 1 files changed, 1 insertions(+), 0 deletions(-)
 create mode 100644 foo
Initial commit


master ✔ /tmp/myapp $
Create a repository!
/tmp $ cd myapp
/tmp/myapp $ git init
Initialized empty Git repository in /private/tmp/myapp/.git/
master ✗ /tmp/myapp $ git add .
master ✗ /tmp/myapp $ git commit -a -m 'Initial commit'
[master (root-commit) 030c6b6] Initial commit
 1 files changed, 1 insertions(+), 0 deletions(-)
 create mode 100644 foo
Initial commit


master ✔ /tmp/myapp $
Create a repository!
/tmp $ cd myapp
/tmp/myapp $ git init
Initialized empty Git repository in /private/tmp/myapp/.git/
master ✗ /tmp/myapp $ git add .
master ✗ /tmp/myapp $ git commit -a -m 'Initial commit'
[master (root-commit) 030c6b6] Initial commit
 1 files changed, 1 insertions(+), 0 deletions(-)
 create mode 100644 foo
Initial commit


master ✔ /tmp/myapp $
Create a repository!
/tmp $ cd myapp
/tmp/myapp $ git init
Initialized empty Git repository in /private/tmp/myapp/.git/
master ✗ /tmp/myapp $ git add .
master ✗ /tmp/myapp $ git commit -a -m 'Initial commit'
[master (root-commit) 030c6b6] Initial commit
 1 files changed, 1 insertions(+), 0 deletions(-)
 create mode 100644 foo
Initial commit


master ✔ /tmp/myapp $
The result

master ✔ /tmp/myapp $ git log

commit 030c6b691993e0f43d78119d9ff1c9e759120d11
Author: Reuven Lerner <reuven@lerner.co.il>
Date:   Thu Jun 30 12:29:29 2011 +0300
    I
Committing in stages

• You can commit all modified files (“git
  commit -a”)
• You can add files to be committed (“git add
  foo.rb”) over time
• Using the staging area gives you
  tremendous flexibility before committing
Remote branches

• A local branch can “track” a remote branch
• Different branches can be on different
  servers — and then you can merge across
  them
• One possible workflow: Read from one
  remote branch, and write to another
Integration
• Git is all small Unix commands
• Easily integrated into text editors, IDEs,
  cron jobs, monitoring, and system tasks
• Example: Continuous integration servers
• Example: Code-analysis tools
• Also: Front ends to SVN and others!
git blame

• Shows the commit, user, and timestamp of
  when each line of a file was changed
• Useful when you want to know who broke
  the build
• Also useful for deflecting blame from
  clients, who think you broke something!
a23c6415 (Magnus Hagander   2009-07-30 09:28:00 +0000   29)
a23c6415 (Magnus Hagander   2009-07-30 09:28:00 +0000   30) #ifdef WIN32
65e806cb (Bruce Momjian     2010-02-26 02:01:40 +0000   31) #define FD_SETSIZE 1024
a23c6415 (Magnus Hagander   2009-07-30 09:28:00 +0000   32) #endif   /* ! WIN32 */
a23c6415 (Magnus Hagander   2009-07-30 09:28:00 +0000   33)
d08741ea (Tom Lane          2001-02-10 02:31:31 +0000   34) #include "postgres_fe.h"
a765db40 (Tatsuo Ishii      2000-01-15 12:38:09 +0000   35)
a765db40 (Tatsuo Ishii      2000-01-15 12:38:09 +0000   36) #include "libpq-fe.h"
a8a198b1 (Itagaki Takahiro 2010-01-06 01:30:03 +0000    37) #include "libpq/pqsignal.h"
3da0dfb4 (Tatsuo Ishii      2009-08-03 15:18:14 +0000   38) #include "portability/instr_time.h"
a765db40 (Tatsuo Ishii      2000-01-15 12:38:09 +0000   39)
d156e1f8 (Tom Lane          2005-10-07 15:34:17 +0000   40) #include <ctype.h>
d156e1f8 (Tom Lane          2005-10-07 15:34:17 +0000   41)
a8a198b1 (Itagaki Takahiro 2010-01-06 01:30:03 +0000    42) #ifndef WIN32
a765db40 (Tatsuo Ishii      2000-01-15 12:38:09 +0000   43) #include <sys/time.h>
a765db40 (Tatsuo Ishii      2000-01-15 12:38:09 +0000   44) #include <unistd.h>
ffda6747 (Tom Lane          2007-09-27 20:39:43 +0000   45) #endif   /* ! WIN32 */
Commit
 a23c6415 (Magnus Hagander   2009-07-30 09:28:00 +0000   29)
 a23c6415 (Magnus Hagander   2009-07-30 09:28:00 +0000   30) #ifdef WIN32
 65e806cb (Bruce Momjian     2010-02-26 02:01:40 +0000   31) #define FD_SETSIZE 1024
 a23c6415 (Magnus Hagander   2009-07-30 09:28:00 +0000   32) #endif   /* ! WIN32 */
 a23c6415 (Magnus Hagander   2009-07-30 09:28:00 +0000   33)
 d08741ea (Tom Lane          2001-02-10 02:31:31 +0000   34) #include "postgres_fe.h"
 a765db40 (Tatsuo Ishii      2000-01-15 12:38:09 +0000   35)
 a765db40 (Tatsuo Ishii      2000-01-15 12:38:09 +0000   36) #include "libpq-fe.h"
 a8a198b1 (Itagaki Takahiro 2010-01-06 01:30:03 +0000    37) #include "libpq/pqsignal.h"
 3da0dfb4 (Tatsuo Ishii      2009-08-03 15:18:14 +0000   38) #include "portability/instr_time.h"
 a765db40 (Tatsuo Ishii      2000-01-15 12:38:09 +0000   39)
 d156e1f8 (Tom Lane          2005-10-07 15:34:17 +0000   40) #include <ctype.h>
 d156e1f8 (Tom Lane          2005-10-07 15:34:17 +0000   41)
 a8a198b1 (Itagaki Takahiro 2010-01-06 01:30:03 +0000    42) #ifndef WIN32
 a765db40 (Tatsuo Ishii      2000-01-15 12:38:09 +0000   43) #include <sys/time.h>
 a765db40 (Tatsuo Ishii      2000-01-15 12:38:09 +0000   44) #include <unistd.h>
 ffda6747 (Tom Lane          2007-09-27 20:39:43 +0000   45) #endif   /* ! WIN32 */
Commit User
 a23c6415 (Magnus Hagander   2009-07-30 09:28:00 +0000   29)
 a23c6415 (Magnus Hagander   2009-07-30 09:28:00 +0000   30) #ifdef WIN32
 65e806cb (Bruce Momjian     2010-02-26 02:01:40 +0000   31) #define FD_SETSIZE 1024
 a23c6415 (Magnus Hagander   2009-07-30 09:28:00 +0000   32) #endif   /* ! WIN32 */
 a23c6415 (Magnus Hagander   2009-07-30 09:28:00 +0000   33)
 d08741ea (Tom Lane          2001-02-10 02:31:31 +0000   34) #include "postgres_fe.h"
 a765db40 (Tatsuo Ishii      2000-01-15 12:38:09 +0000   35)
 a765db40 (Tatsuo Ishii      2000-01-15 12:38:09 +0000   36) #include "libpq-fe.h"
 a8a198b1 (Itagaki Takahiro 2010-01-06 01:30:03 +0000    37) #include "libpq/pqsignal.h"
 3da0dfb4 (Tatsuo Ishii      2009-08-03 15:18:14 +0000   38) #include "portability/instr_time.h"
 a765db40 (Tatsuo Ishii      2000-01-15 12:38:09 +0000   39)
 d156e1f8 (Tom Lane          2005-10-07 15:34:17 +0000   40) #include <ctype.h>
 d156e1f8 (Tom Lane          2005-10-07 15:34:17 +0000   41)
 a8a198b1 (Itagaki Takahiro 2010-01-06 01:30:03 +0000    42) #ifndef WIN32
 a765db40 (Tatsuo Ishii      2000-01-15 12:38:09 +0000   43) #include <sys/time.h>
 a765db40 (Tatsuo Ishii      2000-01-15 12:38:09 +0000   44) #include <unistd.h>
 ffda6747 (Tom Lane          2007-09-27 20:39:43 +0000   45) #endif   /* ! WIN32 */
Commit User                     Timestamp
 a23c6415 (Magnus Hagander   2009-07-30 09:28:00 +0000   29)
 a23c6415 (Magnus Hagander   2009-07-30 09:28:00 +0000   30) #ifdef WIN32
 65e806cb (Bruce Momjian     2010-02-26 02:01:40 +0000   31) #define FD_SETSIZE 1024
 a23c6415 (Magnus Hagander   2009-07-30 09:28:00 +0000   32) #endif   /* ! WIN32 */
 a23c6415 (Magnus Hagander   2009-07-30 09:28:00 +0000   33)
 d08741ea (Tom Lane          2001-02-10 02:31:31 +0000   34) #include "postgres_fe.h"
 a765db40 (Tatsuo Ishii      2000-01-15 12:38:09 +0000   35)
 a765db40 (Tatsuo Ishii      2000-01-15 12:38:09 +0000   36) #include "libpq-fe.h"
 a8a198b1 (Itagaki Takahiro 2010-01-06 01:30:03 +0000    37) #include "libpq/pqsignal.h"
 3da0dfb4 (Tatsuo Ishii      2009-08-03 15:18:14 +0000   38) #include "portability/instr_time.h"
 a765db40 (Tatsuo Ishii      2000-01-15 12:38:09 +0000   39)
 d156e1f8 (Tom Lane          2005-10-07 15:34:17 +0000   40) #include <ctype.h>
 d156e1f8 (Tom Lane          2005-10-07 15:34:17 +0000   41)
 a8a198b1 (Itagaki Takahiro 2010-01-06 01:30:03 +0000    42) #ifndef WIN32
 a765db40 (Tatsuo Ishii      2000-01-15 12:38:09 +0000   43) #include <sys/time.h>
 a765db40 (Tatsuo Ishii      2000-01-15 12:38:09 +0000   44) #include <unistd.h>
 ffda6747 (Tom Lane          2007-09-27 20:39:43 +0000   45) #endif   /* ! WIN32 */
Commit User                     Timestamp                 Line # and code
 a23c6415 (Magnus Hagander   2009-07-30 09:28:00 +0000   29)
 a23c6415 (Magnus Hagander   2009-07-30 09:28:00 +0000   30) #ifdef WIN32
 65e806cb (Bruce Momjian     2010-02-26 02:01:40 +0000   31) #define FD_SETSIZE 1024
 a23c6415 (Magnus Hagander   2009-07-30 09:28:00 +0000   32) #endif   /* ! WIN32 */
 a23c6415 (Magnus Hagander   2009-07-30 09:28:00 +0000   33)
 d08741ea (Tom Lane          2001-02-10 02:31:31 +0000   34) #include "postgres_fe.h"
 a765db40 (Tatsuo Ishii      2000-01-15 12:38:09 +0000   35)
 a765db40 (Tatsuo Ishii      2000-01-15 12:38:09 +0000   36) #include "libpq-fe.h"
 a8a198b1 (Itagaki Takahiro 2010-01-06 01:30:03 +0000    37) #include "libpq/pqsignal.h"
 3da0dfb4 (Tatsuo Ishii      2009-08-03 15:18:14 +0000   38) #include "portability/instr_time.h"
 a765db40 (Tatsuo Ishii      2000-01-15 12:38:09 +0000   39)
 d156e1f8 (Tom Lane          2005-10-07 15:34:17 +0000   40) #include <ctype.h>
 d156e1f8 (Tom Lane          2005-10-07 15:34:17 +0000   41)
 a8a198b1 (Itagaki Takahiro 2010-01-06 01:30:03 +0000    42) #ifndef WIN32
 a765db40 (Tatsuo Ishii      2000-01-15 12:38:09 +0000   43) #include <sys/time.h>
 a765db40 (Tatsuo Ishii      2000-01-15 12:38:09 +0000   44) #include <unistd.h>
 ffda6747 (Tom Lane          2007-09-27 20:39:43 +0000   45) #endif   /* ! WIN32 */
git bisect
• You introduced a bug, but don’t know
  where? Git can find it!
 • Give two endpoints
 • Git does a binary search between them
 • For each commit, tell Git whether it is
    “good” or “bad”
 • This finds the bug very quickly
Stash
• Temporary storage space
• Useful if you have done enough work to
  keep, but not enough for a commit
• Emergency fixes in the middle of working
  on something else
• If you need, put the stash into a new branch
• Oh, you can have multiple stashes
Hooks
• Execute arbitrary code when things happen
• Example: Update submodules automatically
• Example: Send e-mail after a commit
• Example: Heroku uses hooks to deploy a
  new version of your Web app when you
  push to them!
Workflows

• Git supports many, many workflows
 • Traditional centralized server
 • BDFL and users
 • BDFL and Lieutenants
• Do what works for you!
Traditional




Source: ProGit.org
Integration-manager




Source: ProGit.org
Large, BDFL




Source: ProGit.org
Cherry picking

• You can merge specific
  commits, or parts of
  commits
• Amazingly powerful
Rebase
• An alternative to regular merging
• First merge all external commits, then
  replay your changes on top
• Helps to keep you aligned with remote
  branches
• Avoids some merge-conflict issues
Submodules

• A Git repository can point to other
  repositories — submodules
• Break a project into smaller projects
• Git puts the pieces together for you!
Amending commits
• Commits are not sacred in Git
• Rather, they are a tool to manage history
• Change, amend, and edit commits
• Yes, this can be dangerous!
• Also avoids hundreds of “fixed typo”
  commits in a row...
Commercial hosting

• You can host Git repositories on your own
• Want to go commercial? GitHub,
  Gitorious, and many others work great
• GitHub is free for open-source projects,
  and thus very popular
GUIs

• Yes, there are now GUIs for Git
• Windows, Mac, and Unix versions all exist
• Integration with Emacs and other editors
  for hard-core hacker-nerds
• Also: Shell-prompt integration for Unix
In short
• Git has completely changed how I develop
  code, both alone and with others
• The speed and easy branching/merging are
  game-changers
• It’s really not that hard to start using...
• ... and once you start, you’ll never want to
  go back to CVS or SVN
Want to learn more?
• Mailing lists, wikis, and blogs
 • http://git-scm.com/
 • http://progit.org/
 • http://gitimmersion.com/
• I’m probably going to offer Git training
  soon — let me know if you’re interested!
Thanks!
(Any questions?)
     reuven@lerner.co.il
   http://www.lerner.co.il/
        054-496-8405
“reuvenlerner” on Skype/AIM

Contenu connexe

Tendances

New Views on your History with git replace
New Views on your History with git replaceNew Views on your History with git replace
New Views on your History with git replaceChristian Couder
 
Working with multiple git repositories
Working with multiple git repositoriesWorking with multiple git repositories
Working with multiple git repositoriesJulien Pivotto
 
Introduction to Git, DrupalCamp LA 2015
Introduction to Git, DrupalCamp LA 2015Introduction to Git, DrupalCamp LA 2015
Introduction to Git, DrupalCamp LA 2015mwrather
 
Deep dark-side of git: How git works internally
Deep dark-side of git: How git works internallyDeep dark-side of git: How git works internally
Deep dark-side of git: How git works internallySeongJae Park
 
slides.pdf
slides.pdfslides.pdf
slides.pdfvidsvagi
 
Github - Git Training Slides: Foundations
Github - Git Training Slides: FoundationsGithub - Git Training Slides: Foundations
Github - Git Training Slides: FoundationsLee Hanxue
 
Introduction to Git
Introduction to GitIntroduction to Git
Introduction to GitColin Su
 
Starting with Git & GitHub
Starting with Git & GitHubStarting with Git & GitHub
Starting with Git & GitHubNicolás Tourné
 
Git: An introduction of plumbing and porcelain commands
Git: An introduction of plumbing and porcelain commandsGit: An introduction of plumbing and porcelain commands
Git: An introduction of plumbing and porcelain commandsth507
 
Git and GitHub
Git and GitHubGit and GitHub
Git and GitHubJames Gray
 
Git One Day Training Notes
Git One Day Training NotesGit One Day Training Notes
Git One Day Training Notesglen_a_smith
 
Code review and automated testing for Puppet code
Code review and automated testing for Puppet codeCode review and automated testing for Puppet code
Code review and automated testing for Puppet codewzzrd
 

Tendances (20)

New Views on your History with git replace
New Views on your History with git replaceNew Views on your History with git replace
New Views on your History with git replace
 
Working with multiple git repositories
Working with multiple git repositoriesWorking with multiple git repositories
Working with multiple git repositories
 
Inside GitHub with Chris Wanstrath
Inside GitHub with Chris WanstrathInside GitHub with Chris Wanstrath
Inside GitHub with Chris Wanstrath
 
Introduction to Git, DrupalCamp LA 2015
Introduction to Git, DrupalCamp LA 2015Introduction to Git, DrupalCamp LA 2015
Introduction to Git, DrupalCamp LA 2015
 
Hello, Git!
Hello, Git!Hello, Git!
Hello, Git!
 
Logstash and friends
Logstash and friendsLogstash and friends
Logstash and friends
 
Deep dark-side of git: How git works internally
Deep dark-side of git: How git works internallyDeep dark-side of git: How git works internally
Deep dark-side of git: How git works internally
 
slides.pdf
slides.pdfslides.pdf
slides.pdf
 
git and github
git and githubgit and github
git and github
 
Introduction to Git (part 1)
Introduction to Git (part 1)Introduction to Git (part 1)
Introduction to Git (part 1)
 
Github - Git Training Slides: Foundations
Github - Git Training Slides: FoundationsGithub - Git Training Slides: Foundations
Github - Git Training Slides: Foundations
 
Introduction to Git
Introduction to GitIntroduction to Git
Introduction to Git
 
Starting with Git & GitHub
Starting with Git & GitHubStarting with Git & GitHub
Starting with Git & GitHub
 
Git 101 for Beginners
Git 101 for Beginners Git 101 for Beginners
Git 101 for Beginners
 
Git: An introduction of plumbing and porcelain commands
Git: An introduction of plumbing and porcelain commandsGit: An introduction of plumbing and porcelain commands
Git: An introduction of plumbing and porcelain commands
 
Git and GitHub
Git and GitHubGit and GitHub
Git and GitHub
 
Git One Day Training Notes
Git One Day Training NotesGit One Day Training Notes
Git One Day Training Notes
 
Now i git it!!!
Now i git it!!!Now i git it!!!
Now i git it!!!
 
Git training v10
Git training v10Git training v10
Git training v10
 
Code review and automated testing for Puppet code
Code review and automated testing for Puppet codeCode review and automated testing for Puppet code
Code review and automated testing for Puppet code
 

En vedette

Big Data — Your new best friend
Big Data — Your new best friendBig Data — Your new best friend
Big Data — Your new best friendReuven Lerner
 
PostgreSQL talk, Database 2011 conference
PostgreSQL talk, Database 2011 conferencePostgreSQL talk, Database 2011 conference
PostgreSQL talk, Database 2011 conferenceReuven Lerner
 
What can Ruby learn from Python (and vice versa)?
What can Ruby learn from Python (and vice versa)?What can Ruby learn from Python (and vice versa)?
What can Ruby learn from Python (and vice versa)?Reuven Lerner
 
Functional Python Webinar from October 22nd, 2014
Functional Python Webinar from October 22nd, 2014Functional Python Webinar from October 22nd, 2014
Functional Python Webinar from October 22nd, 2014Reuven Lerner
 
Web APIs: The future of software
Web APIs: The future of softwareWeb APIs: The future of software
Web APIs: The future of softwareReuven Lerner
 
Dynamic languages, for software craftmanship group
Dynamic languages, for software craftmanship groupDynamic languages, for software craftmanship group
Dynamic languages, for software craftmanship groupReuven Lerner
 
Python's magic methods
Python's magic methodsPython's magic methods
Python's magic methodsReuven Lerner
 
Technical training business talk.key
Technical training business talk.keyTechnical training business talk.key
Technical training business talk.keyReuven Lerner
 
Intro to cloud computing — MegaCOMM 2013, Jerusalem
Intro to cloud computing — MegaCOMM 2013, JerusalemIntro to cloud computing — MegaCOMM 2013, Jerusalem
Intro to cloud computing — MegaCOMM 2013, JerusalemReuven Lerner
 

En vedette (12)

Big Data — Your new best friend
Big Data — Your new best friendBig Data — Your new best friend
Big Data — Your new best friend
 
PostgreSQL talk, Database 2011 conference
PostgreSQL talk, Database 2011 conferencePostgreSQL talk, Database 2011 conference
PostgreSQL talk, Database 2011 conference
 
What can Ruby learn from Python (and vice versa)?
What can Ruby learn from Python (and vice versa)?What can Ruby learn from Python (and vice versa)?
What can Ruby learn from Python (and vice versa)?
 
ActiveRecord 2.3
ActiveRecord 2.3ActiveRecord 2.3
ActiveRecord 2.3
 
Functional Python Webinar from October 22nd, 2014
Functional Python Webinar from October 22nd, 2014Functional Python Webinar from October 22nd, 2014
Functional Python Webinar from October 22nd, 2014
 
Web APIs: The future of software
Web APIs: The future of softwareWeb APIs: The future of software
Web APIs: The future of software
 
Rails console
Rails consoleRails console
Rails console
 
Dynamic languages, for software craftmanship group
Dynamic languages, for software craftmanship groupDynamic languages, for software craftmanship group
Dynamic languages, for software craftmanship group
 
Python's magic methods
Python's magic methodsPython's magic methods
Python's magic methods
 
PostgreSQL
PostgreSQLPostgreSQL
PostgreSQL
 
Technical training business talk.key
Technical training business talk.keyTechnical training business talk.key
Technical training business talk.key
 
Intro to cloud computing — MegaCOMM 2013, Jerusalem
Intro to cloud computing — MegaCOMM 2013, JerusalemIntro to cloud computing — MegaCOMM 2013, Jerusalem
Intro to cloud computing — MegaCOMM 2013, Jerusalem
 

Similaire à Git talk from Open 2011 conference in Israel

Source Code Management with Git
Source Code Management with GitSource Code Management with Git
Source Code Management with GitThings Lab
 
Introduction to Git
Introduction to GitIntroduction to Git
Introduction to Gitatishgoswami
 
Beginner's Guide to Version Control with Git
Beginner's Guide to Version Control with GitBeginner's Guide to Version Control with Git
Beginner's Guide to Version Control with GitRobert Lee-Cann
 
Git for Android Developers
Git for Android DevelopersGit for Android Developers
Git for Android DevelopersTony Hillerson
 
Open Source Tools for Leveling Up Operations FOSSET 2014
Open Source Tools for Leveling Up Operations FOSSET 2014Open Source Tools for Leveling Up Operations FOSSET 2014
Open Source Tools for Leveling Up Operations FOSSET 2014Mandi Walls
 
Git in gear: How to track changes, travel back in time, and code nicely with ...
Git in gear: How to track changes, travel back in time, and code nicely with ...Git in gear: How to track changes, travel back in time, and code nicely with ...
Git in gear: How to track changes, travel back in time, and code nicely with ...fureigh
 
Geecon11 - Git: a Gentle InTroduction
Geecon11 -  Git: a Gentle InTroductionGeecon11 -  Git: a Gentle InTroduction
Geecon11 - Git: a Gentle InTroductionBruno Bossola
 
GIT: a Gentle InTroduction
GIT: a Gentle InTroductionGIT: a Gentle InTroduction
GIT: a Gentle InTroductionCodemotion
 
Introduction to GitHub, Open Source and Tech Article
Introduction to GitHub, Open Source and Tech ArticleIntroduction to GitHub, Open Source and Tech Article
Introduction to GitHub, Open Source and Tech ArticlePRIYATHAMDARISI
 
Git installation and configuration
Git installation and configurationGit installation and configuration
Git installation and configurationKishor Kumar
 
Updated non-lab version of Level Up. Delivered at LOPSA-East, May 3, 2014.
Updated non-lab version of Level Up. Delivered at LOPSA-East, May 3, 2014.Updated non-lab version of Level Up. Delivered at LOPSA-East, May 3, 2014.
Updated non-lab version of Level Up. Delivered at LOPSA-East, May 3, 2014.Mandi Walls
 
Git - (a) Gentle InTroduction
Git - (a) Gentle InTroductionGit - (a) Gentle InTroduction
Git - (a) Gentle InTroductionBruno Bossola
 
Learn Git form Beginners to Master
Learn Git form Beginners to MasterLearn Git form Beginners to Master
Learn Git form Beginners to MasterC. M. Abdullah Khan
 
Intro to git (UT biocomputing 2015)
Intro to git (UT biocomputing 2015)Intro to git (UT biocomputing 2015)
Intro to git (UT biocomputing 2015)chenghlee
 

Similaire à Git talk from Open 2011 conference in Israel (20)

Source Code Management with Git
Source Code Management with GitSource Code Management with Git
Source Code Management with Git
 
Introduction to Git
Introduction to GitIntroduction to Git
Introduction to Git
 
3 Git
3 Git3 Git
3 Git
 
Beginner's Guide to Version Control with Git
Beginner's Guide to Version Control with GitBeginner's Guide to Version Control with Git
Beginner's Guide to Version Control with Git
 
Git for Android Developers
Git for Android DevelopersGit for Android Developers
Git for Android Developers
 
Techoalien git
Techoalien gitTechoalien git
Techoalien git
 
Techoalien git
Techoalien gitTechoalien git
Techoalien git
 
Techoalien git
Techoalien gitTechoalien git
Techoalien git
 
Open Source Tools for Leveling Up Operations FOSSET 2014
Open Source Tools for Leveling Up Operations FOSSET 2014Open Source Tools for Leveling Up Operations FOSSET 2014
Open Source Tools for Leveling Up Operations FOSSET 2014
 
Git in gear: How to track changes, travel back in time, and code nicely with ...
Git in gear: How to track changes, travel back in time, and code nicely with ...Git in gear: How to track changes, travel back in time, and code nicely with ...
Git in gear: How to track changes, travel back in time, and code nicely with ...
 
Geecon11 - Git: a Gentle InTroduction
Geecon11 -  Git: a Gentle InTroductionGeecon11 -  Git: a Gentle InTroduction
Geecon11 - Git: a Gentle InTroduction
 
GIT: a Gentle InTroduction
GIT: a Gentle InTroductionGIT: a Gentle InTroduction
GIT: a Gentle InTroduction
 
Introduction to GitHub, Open Source and Tech Article
Introduction to GitHub, Open Source and Tech ArticleIntroduction to GitHub, Open Source and Tech Article
Introduction to GitHub, Open Source and Tech Article
 
Git installation and configuration
Git installation and configurationGit installation and configuration
Git installation and configuration
 
Git
GitGit
Git
 
Updated non-lab version of Level Up. Delivered at LOPSA-East, May 3, 2014.
Updated non-lab version of Level Up. Delivered at LOPSA-East, May 3, 2014.Updated non-lab version of Level Up. Delivered at LOPSA-East, May 3, 2014.
Updated non-lab version of Level Up. Delivered at LOPSA-East, May 3, 2014.
 
Git - (a) Gentle InTroduction
Git - (a) Gentle InTroductionGit - (a) Gentle InTroduction
Git - (a) Gentle InTroduction
 
Learn Git form Beginners to Master
Learn Git form Beginners to MasterLearn Git form Beginners to Master
Learn Git form Beginners to Master
 
Intro to git (UT biocomputing 2015)
Intro to git (UT biocomputing 2015)Intro to git (UT biocomputing 2015)
Intro to git (UT biocomputing 2015)
 
Git hub
Git hubGit hub
Git hub
 

Plus de Reuven Lerner

PostgreSQL, your NoSQL database
PostgreSQL, your NoSQL databasePostgreSQL, your NoSQL database
PostgreSQL, your NoSQL databaseReuven Lerner
 
Modern Web technologies (and why you should care): Megacomm, Jerusalem, Febru...
Modern Web technologies (and why you should care): Megacomm, Jerusalem, Febru...Modern Web technologies (and why you should care): Megacomm, Jerusalem, Febru...
Modern Web technologies (and why you should care): Megacomm, Jerusalem, Febru...Reuven Lerner
 
Rails development environment talk
Rails development environment talkRails development environment talk
Rails development environment talkReuven Lerner
 
Modern Web Technologies — Jerusalem Web Professionals, January 2011
Modern Web Technologies — Jerusalem Web Professionals, January 2011Modern Web Technologies — Jerusalem Web Professionals, January 2011
Modern Web Technologies — Jerusalem Web Professionals, January 2011Reuven Lerner
 

Plus de Reuven Lerner (9)

PostgreSQL, your NoSQL database
PostgreSQL, your NoSQL databasePostgreSQL, your NoSQL database
PostgreSQL, your NoSQL database
 
Rails israel 2013
Rails israel 2013Rails israel 2013
Rails israel 2013
 
Rails traps
Rails trapsRails traps
Rails traps
 
Modern Web technologies (and why you should care): Megacomm, Jerusalem, Febru...
Modern Web technologies (and why you should care): Megacomm, Jerusalem, Febru...Modern Web technologies (and why you should care): Megacomm, Jerusalem, Febru...
Modern Web technologies (and why you should care): Megacomm, Jerusalem, Febru...
 
Rails development environment talk
Rails development environment talkRails development environment talk
Rails development environment talk
 
Modern Web Technologies — Jerusalem Web Professionals, January 2011
Modern Web Technologies — Jerusalem Web Professionals, January 2011Modern Web Technologies — Jerusalem Web Professionals, January 2011
Modern Web Technologies — Jerusalem Web Professionals, January 2011
 
Ruby objects
Ruby objectsRuby objects
Ruby objects
 
Rails tools
Rails toolsRails tools
Rails tools
 
Why ruby and rails
Why ruby and railsWhy ruby and rails
Why ruby and rails
 

Dernier

Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...AliaaTarek5
 
Visualising and forecasting stocks using Dash
Visualising and forecasting stocks using DashVisualising and forecasting stocks using Dash
Visualising and forecasting stocks using Dashnarutouzumaki53779
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
Ryan Mahoney - Will Artificial Intelligence Replace Real Estate Agents
Ryan Mahoney - Will Artificial Intelligence Replace Real Estate AgentsRyan Mahoney - Will Artificial Intelligence Replace Real Estate Agents
Ryan Mahoney - Will Artificial Intelligence Replace Real Estate AgentsRyan Mahoney
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rick Flair
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demoHarshalMandlekar2
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterMydbops
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 

Dernier (20)

Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
 
Visualising and forecasting stocks using Dash
Visualising and forecasting stocks using DashVisualising and forecasting stocks using Dash
Visualising and forecasting stocks using Dash
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
Ryan Mahoney - Will Artificial Intelligence Replace Real Estate Agents
Ryan Mahoney - Will Artificial Intelligence Replace Real Estate AgentsRyan Mahoney - Will Artificial Intelligence Replace Real Estate Agents
Ryan Mahoney - Will Artificial Intelligence Replace Real Estate Agents
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demo
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL Router
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 

Git talk from Open 2011 conference in Israel

  • 1. Git Reuven M. Lerner • reuven@lerner.co.il Open Israel Conference June 30th, 2011
  • 2. Who am I? • Web developer, software architect, consultant, lecturer/trainer • Linux Journal columnist since 1996 • Mostly Ruby on Rails + PostgreSQL, but also Python, PHP, jQuery, and lots more... • Git user (and enthusiast) since 2008
  • 4. Time machine • Return to any point in a project’s history • Find out how files, folders have changed • Learn which user made which changes
  • 5. Backup • Never fear that you’ve deleted a file — just rewind the history • Everything is recorded, can be undone
  • 6. Maintenance tool • “Tag” releases • Who is to blame for a particular bug? • When did we introduce a particular problem? • Deploy specific versions on specific servers
  • 7. Scratchpad • Try out new ideas • Experiment with alternative techniques • Upgrade a library • Refactor without affecting the “live” code base
  • 8. Collaboration tool • Work without fear of “stomping” on someone else’s code • Identify conflicts between what developers wrote • Mix and match teams for projects
  • 9. Version control is great • If you’re a programmer and not using version control, you’re really missing out • It’s also good for non-programs, such as configuration files • If you’re a CTO/team leader/VP R&D and your people aren’t using version control, you’re inviting disaster
  • 10. What do people use? • RCS (ancient history) • CVS (should be ancient history) • Subversion (“a better CVS”) • SourceSafe • Perforce • lots of other systems
  • 11. Problems with these • Work requires a server connection • (You can work, but not commit.) • Branching and merging is painful and slow • So no one does it! • Enforces a particular workflow • More code, more developers — slower VC
  • 12. Distributed version control • Distributed: Everyone is their own server! • Everyone has a complete commit history • No single point of failure • Commit whenever you want (i.e., often) • Merge when two repositories connect
  • 13. Git • Linus needed a VCS... so he wrote one! • Fast • Accurate • Distributed • Massively scalable • Super flexible
  • 14. Open-source Git users • Linux kernel • PostgreSQL • Ruby language • Ruby on Rails • Perl language • among many, many others
  • 15. Give me details! • What does Git do that others don’t? • Why do I claim that Git has changed my life?
  • 16. Branching & merging • Branching and merging is both easy and fast in Git • I often branch and merge several times in a given day • When I used SVN, I would do everything in my power to avoid branching, because merges were long and difficult
  • 17. Branching & merging • Create a branch: git checkout -b new-branch • Merge commits from other-branch git merge other-branch • Yes, it’s really that easy. • You don’t even have to change directories!
  • 18. Easy branching changes everything! • Every new feature goes in a branch • Merging becomes easy, fast, and natural • Side projects are stored, not kept out of version control for fear of “contamination” • Commit, commit, commit all of the time, in an appropriate branch — never lose work!
  • 19. Local repository is great • Work without a network connection • Commits, merges, and switching branches are nearly instantaneous • Reports and logs are super-fast • “Show me all files modified on Tuesday of last week” produces immediate resultss
  • 20. Create a repository! /tmp $ cd myapp /tmp/myapp $ git init Initialized empty Git repository in /private/tmp/myapp/.git/ master ✗ /tmp/myapp $ git add . master ✗ /tmp/myapp $ git commit -a -m 'Initial commit' [master (root-commit) 030c6b6] Initial commit 1 files changed, 1 insertions(+), 0 deletions(-) create mode 100644 foo Initial commit master ✔ /tmp/myapp $
  • 21. Create a repository! /tmp $ cd myapp /tmp/myapp $ git init Initialized empty Git repository in /private/tmp/myapp/.git/ master ✗ /tmp/myapp $ git add . master ✗ /tmp/myapp $ git commit -a -m 'Initial commit' [master (root-commit) 030c6b6] Initial commit 1 files changed, 1 insertions(+), 0 deletions(-) create mode 100644 foo Initial commit master ✔ /tmp/myapp $
  • 22. Create a repository! /tmp $ cd myapp /tmp/myapp $ git init Initialized empty Git repository in /private/tmp/myapp/.git/ master ✗ /tmp/myapp $ git add . master ✗ /tmp/myapp $ git commit -a -m 'Initial commit' [master (root-commit) 030c6b6] Initial commit 1 files changed, 1 insertions(+), 0 deletions(-) create mode 100644 foo Initial commit master ✔ /tmp/myapp $
  • 23. Create a repository! /tmp $ cd myapp /tmp/myapp $ git init Initialized empty Git repository in /private/tmp/myapp/.git/ master ✗ /tmp/myapp $ git add . master ✗ /tmp/myapp $ git commit -a -m 'Initial commit' [master (root-commit) 030c6b6] Initial commit 1 files changed, 1 insertions(+), 0 deletions(-) create mode 100644 foo Initial commit master ✔ /tmp/myapp $
  • 24. Create a repository! /tmp $ cd myapp /tmp/myapp $ git init Initialized empty Git repository in /private/tmp/myapp/.git/ master ✗ /tmp/myapp $ git add . master ✗ /tmp/myapp $ git commit -a -m 'Initial commit' [master (root-commit) 030c6b6] Initial commit 1 files changed, 1 insertions(+), 0 deletions(-) create mode 100644 foo Initial commit master ✔ /tmp/myapp $
  • 25. Create a repository! /tmp $ cd myapp /tmp/myapp $ git init Initialized empty Git repository in /private/tmp/myapp/.git/ master ✗ /tmp/myapp $ git add . master ✗ /tmp/myapp $ git commit -a -m 'Initial commit' [master (root-commit) 030c6b6] Initial commit 1 files changed, 1 insertions(+), 0 deletions(-) create mode 100644 foo Initial commit master ✔ /tmp/myapp $
  • 26. The result master ✔ /tmp/myapp $ git log commit 030c6b691993e0f43d78119d9ff1c9e759120d11 Author: Reuven Lerner <reuven@lerner.co.il> Date: Thu Jun 30 12:29:29 2011 +0300 I
  • 27. Committing in stages • You can commit all modified files (“git commit -a”) • You can add files to be committed (“git add foo.rb”) over time • Using the staging area gives you tremendous flexibility before committing
  • 28. Remote branches • A local branch can “track” a remote branch • Different branches can be on different servers — and then you can merge across them • One possible workflow: Read from one remote branch, and write to another
  • 29. Integration • Git is all small Unix commands • Easily integrated into text editors, IDEs, cron jobs, monitoring, and system tasks • Example: Continuous integration servers • Example: Code-analysis tools • Also: Front ends to SVN and others!
  • 30. git blame • Shows the commit, user, and timestamp of when each line of a file was changed • Useful when you want to know who broke the build • Also useful for deflecting blame from clients, who think you broke something!
  • 31. a23c6415 (Magnus Hagander 2009-07-30 09:28:00 +0000 29) a23c6415 (Magnus Hagander 2009-07-30 09:28:00 +0000 30) #ifdef WIN32 65e806cb (Bruce Momjian 2010-02-26 02:01:40 +0000 31) #define FD_SETSIZE 1024 a23c6415 (Magnus Hagander 2009-07-30 09:28:00 +0000 32) #endif /* ! WIN32 */ a23c6415 (Magnus Hagander 2009-07-30 09:28:00 +0000 33) d08741ea (Tom Lane 2001-02-10 02:31:31 +0000 34) #include "postgres_fe.h" a765db40 (Tatsuo Ishii 2000-01-15 12:38:09 +0000 35) a765db40 (Tatsuo Ishii 2000-01-15 12:38:09 +0000 36) #include "libpq-fe.h" a8a198b1 (Itagaki Takahiro 2010-01-06 01:30:03 +0000 37) #include "libpq/pqsignal.h" 3da0dfb4 (Tatsuo Ishii 2009-08-03 15:18:14 +0000 38) #include "portability/instr_time.h" a765db40 (Tatsuo Ishii 2000-01-15 12:38:09 +0000 39) d156e1f8 (Tom Lane 2005-10-07 15:34:17 +0000 40) #include <ctype.h> d156e1f8 (Tom Lane 2005-10-07 15:34:17 +0000 41) a8a198b1 (Itagaki Takahiro 2010-01-06 01:30:03 +0000 42) #ifndef WIN32 a765db40 (Tatsuo Ishii 2000-01-15 12:38:09 +0000 43) #include <sys/time.h> a765db40 (Tatsuo Ishii 2000-01-15 12:38:09 +0000 44) #include <unistd.h> ffda6747 (Tom Lane 2007-09-27 20:39:43 +0000 45) #endif /* ! WIN32 */
  • 32. Commit a23c6415 (Magnus Hagander 2009-07-30 09:28:00 +0000 29) a23c6415 (Magnus Hagander 2009-07-30 09:28:00 +0000 30) #ifdef WIN32 65e806cb (Bruce Momjian 2010-02-26 02:01:40 +0000 31) #define FD_SETSIZE 1024 a23c6415 (Magnus Hagander 2009-07-30 09:28:00 +0000 32) #endif /* ! WIN32 */ a23c6415 (Magnus Hagander 2009-07-30 09:28:00 +0000 33) d08741ea (Tom Lane 2001-02-10 02:31:31 +0000 34) #include "postgres_fe.h" a765db40 (Tatsuo Ishii 2000-01-15 12:38:09 +0000 35) a765db40 (Tatsuo Ishii 2000-01-15 12:38:09 +0000 36) #include "libpq-fe.h" a8a198b1 (Itagaki Takahiro 2010-01-06 01:30:03 +0000 37) #include "libpq/pqsignal.h" 3da0dfb4 (Tatsuo Ishii 2009-08-03 15:18:14 +0000 38) #include "portability/instr_time.h" a765db40 (Tatsuo Ishii 2000-01-15 12:38:09 +0000 39) d156e1f8 (Tom Lane 2005-10-07 15:34:17 +0000 40) #include <ctype.h> d156e1f8 (Tom Lane 2005-10-07 15:34:17 +0000 41) a8a198b1 (Itagaki Takahiro 2010-01-06 01:30:03 +0000 42) #ifndef WIN32 a765db40 (Tatsuo Ishii 2000-01-15 12:38:09 +0000 43) #include <sys/time.h> a765db40 (Tatsuo Ishii 2000-01-15 12:38:09 +0000 44) #include <unistd.h> ffda6747 (Tom Lane 2007-09-27 20:39:43 +0000 45) #endif /* ! WIN32 */
  • 33. Commit User a23c6415 (Magnus Hagander 2009-07-30 09:28:00 +0000 29) a23c6415 (Magnus Hagander 2009-07-30 09:28:00 +0000 30) #ifdef WIN32 65e806cb (Bruce Momjian 2010-02-26 02:01:40 +0000 31) #define FD_SETSIZE 1024 a23c6415 (Magnus Hagander 2009-07-30 09:28:00 +0000 32) #endif /* ! WIN32 */ a23c6415 (Magnus Hagander 2009-07-30 09:28:00 +0000 33) d08741ea (Tom Lane 2001-02-10 02:31:31 +0000 34) #include "postgres_fe.h" a765db40 (Tatsuo Ishii 2000-01-15 12:38:09 +0000 35) a765db40 (Tatsuo Ishii 2000-01-15 12:38:09 +0000 36) #include "libpq-fe.h" a8a198b1 (Itagaki Takahiro 2010-01-06 01:30:03 +0000 37) #include "libpq/pqsignal.h" 3da0dfb4 (Tatsuo Ishii 2009-08-03 15:18:14 +0000 38) #include "portability/instr_time.h" a765db40 (Tatsuo Ishii 2000-01-15 12:38:09 +0000 39) d156e1f8 (Tom Lane 2005-10-07 15:34:17 +0000 40) #include <ctype.h> d156e1f8 (Tom Lane 2005-10-07 15:34:17 +0000 41) a8a198b1 (Itagaki Takahiro 2010-01-06 01:30:03 +0000 42) #ifndef WIN32 a765db40 (Tatsuo Ishii 2000-01-15 12:38:09 +0000 43) #include <sys/time.h> a765db40 (Tatsuo Ishii 2000-01-15 12:38:09 +0000 44) #include <unistd.h> ffda6747 (Tom Lane 2007-09-27 20:39:43 +0000 45) #endif /* ! WIN32 */
  • 34. Commit User Timestamp a23c6415 (Magnus Hagander 2009-07-30 09:28:00 +0000 29) a23c6415 (Magnus Hagander 2009-07-30 09:28:00 +0000 30) #ifdef WIN32 65e806cb (Bruce Momjian 2010-02-26 02:01:40 +0000 31) #define FD_SETSIZE 1024 a23c6415 (Magnus Hagander 2009-07-30 09:28:00 +0000 32) #endif /* ! WIN32 */ a23c6415 (Magnus Hagander 2009-07-30 09:28:00 +0000 33) d08741ea (Tom Lane 2001-02-10 02:31:31 +0000 34) #include "postgres_fe.h" a765db40 (Tatsuo Ishii 2000-01-15 12:38:09 +0000 35) a765db40 (Tatsuo Ishii 2000-01-15 12:38:09 +0000 36) #include "libpq-fe.h" a8a198b1 (Itagaki Takahiro 2010-01-06 01:30:03 +0000 37) #include "libpq/pqsignal.h" 3da0dfb4 (Tatsuo Ishii 2009-08-03 15:18:14 +0000 38) #include "portability/instr_time.h" a765db40 (Tatsuo Ishii 2000-01-15 12:38:09 +0000 39) d156e1f8 (Tom Lane 2005-10-07 15:34:17 +0000 40) #include <ctype.h> d156e1f8 (Tom Lane 2005-10-07 15:34:17 +0000 41) a8a198b1 (Itagaki Takahiro 2010-01-06 01:30:03 +0000 42) #ifndef WIN32 a765db40 (Tatsuo Ishii 2000-01-15 12:38:09 +0000 43) #include <sys/time.h> a765db40 (Tatsuo Ishii 2000-01-15 12:38:09 +0000 44) #include <unistd.h> ffda6747 (Tom Lane 2007-09-27 20:39:43 +0000 45) #endif /* ! WIN32 */
  • 35. Commit User Timestamp Line # and code a23c6415 (Magnus Hagander 2009-07-30 09:28:00 +0000 29) a23c6415 (Magnus Hagander 2009-07-30 09:28:00 +0000 30) #ifdef WIN32 65e806cb (Bruce Momjian 2010-02-26 02:01:40 +0000 31) #define FD_SETSIZE 1024 a23c6415 (Magnus Hagander 2009-07-30 09:28:00 +0000 32) #endif /* ! WIN32 */ a23c6415 (Magnus Hagander 2009-07-30 09:28:00 +0000 33) d08741ea (Tom Lane 2001-02-10 02:31:31 +0000 34) #include "postgres_fe.h" a765db40 (Tatsuo Ishii 2000-01-15 12:38:09 +0000 35) a765db40 (Tatsuo Ishii 2000-01-15 12:38:09 +0000 36) #include "libpq-fe.h" a8a198b1 (Itagaki Takahiro 2010-01-06 01:30:03 +0000 37) #include "libpq/pqsignal.h" 3da0dfb4 (Tatsuo Ishii 2009-08-03 15:18:14 +0000 38) #include "portability/instr_time.h" a765db40 (Tatsuo Ishii 2000-01-15 12:38:09 +0000 39) d156e1f8 (Tom Lane 2005-10-07 15:34:17 +0000 40) #include <ctype.h> d156e1f8 (Tom Lane 2005-10-07 15:34:17 +0000 41) a8a198b1 (Itagaki Takahiro 2010-01-06 01:30:03 +0000 42) #ifndef WIN32 a765db40 (Tatsuo Ishii 2000-01-15 12:38:09 +0000 43) #include <sys/time.h> a765db40 (Tatsuo Ishii 2000-01-15 12:38:09 +0000 44) #include <unistd.h> ffda6747 (Tom Lane 2007-09-27 20:39:43 +0000 45) #endif /* ! WIN32 */
  • 36. git bisect • You introduced a bug, but don’t know where? Git can find it! • Give two endpoints • Git does a binary search between them • For each commit, tell Git whether it is “good” or “bad” • This finds the bug very quickly
  • 37. Stash • Temporary storage space • Useful if you have done enough work to keep, but not enough for a commit • Emergency fixes in the middle of working on something else • If you need, put the stash into a new branch • Oh, you can have multiple stashes
  • 38. Hooks • Execute arbitrary code when things happen • Example: Update submodules automatically • Example: Send e-mail after a commit • Example: Heroku uses hooks to deploy a new version of your Web app when you push to them!
  • 39. Workflows • Git supports many, many workflows • Traditional centralized server • BDFL and users • BDFL and Lieutenants • Do what works for you!
  • 43. Cherry picking • You can merge specific commits, or parts of commits • Amazingly powerful
  • 44. Rebase • An alternative to regular merging • First merge all external commits, then replay your changes on top • Helps to keep you aligned with remote branches • Avoids some merge-conflict issues
  • 45. Submodules • A Git repository can point to other repositories — submodules • Break a project into smaller projects • Git puts the pieces together for you!
  • 46. Amending commits • Commits are not sacred in Git • Rather, they are a tool to manage history • Change, amend, and edit commits • Yes, this can be dangerous! • Also avoids hundreds of “fixed typo” commits in a row...
  • 47. Commercial hosting • You can host Git repositories on your own • Want to go commercial? GitHub, Gitorious, and many others work great • GitHub is free for open-source projects, and thus very popular
  • 48.
  • 49. GUIs • Yes, there are now GUIs for Git • Windows, Mac, and Unix versions all exist • Integration with Emacs and other editors for hard-core hacker-nerds • Also: Shell-prompt integration for Unix
  • 50. In short • Git has completely changed how I develop code, both alone and with others • The speed and easy branching/merging are game-changers • It’s really not that hard to start using... • ... and once you start, you’ll never want to go back to CVS or SVN
  • 51. Want to learn more? • Mailing lists, wikis, and blogs • http://git-scm.com/ • http://progit.org/ • http://gitimmersion.com/ • I’m probably going to offer Git training soon — let me know if you’re interested!
  • 52. Thanks! (Any questions?) reuven@lerner.co.il http://www.lerner.co.il/ 054-496-8405 “reuvenlerner” on Skype/AIM

Notes de l'éditeur

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n
  17. \n
  18. \n
  19. \n
  20. \n
  21. \n
  22. \n
  23. \n
  24. \n
  25. \n
  26. \n
  27. \n
  28. \n
  29. \n
  30. \n
  31. \n
  32. \n
  33. \n
  34. \n
  35. \n
  36. \n
  37. \n
  38. \n
  39. \n
  40. \n
  41. \n
  42. \n
  43. \n
  44. \n
  45. \n
  46. \n
  47. \n
  48. \n
  49. \n
  50. \n
  51. \n
  52. \n
  53. \n
  54. \n
  55. \n
  56. \n
  57. \n
  58. \n
  59. \n
  60. \n
  61. \n