git presentation

16

Upload: julien-renaux

Post on 14-Jul-2015

3.544 views

Category:

Technology


0 download

TRANSCRIPT

Agenda

● Git introduction● Why Git?● Git VS Subversion● Basic Commands● Branching & Merging● Typical Workflow

Git introduction

● Distributed Version Control System

● Speed & Efficiency

● Decentralized

Why Git?

● Distributed● Non-linear● Scale

Why Git?

Distributed– Local repo

– With entire dev history

– Off-line work

– Remote sync

Why Git?

Non-linear– Rapid branching and merging

– merging more often than writing

– passing around various reviewers

Why Git?

Scale– Efficient handling of large projects

– Fast

– scalable

Git VS Subversion

Git is not better than Subversion. But is also not worse. It's different.

The key difference is that it is decentralized. Imagine you are a developer on the road, you develop on your laptop and you want to have source control so that you can go back 3 hours.

With Subversion, you have a Problem: The SVN Repository may be in a location you can't reach (in your company, and you don't have Internet at the moment), you cannot commit. If you want to make a copy of your code, you have to literally copy/paste it.

With Git, you do not have this problem. Your local copy is a repository, and you can commit to it and get all benefits of source control. When you regain connectivity to the main repository, you can commit against it.

SVN: has the advantage that it's MUCH simpler to learn: There is your repository, all changes to towards it, if you know how to create, commit and checkout and you're ready to go and can pickup stuff like branching, update etc. later on.

Git: has the advantage that it's MUCH better suited if some developers are not always connected to the master repository. Also, it's much faster than SVN. And from what I hear, branching and merging support is a lot better (which is to be expected, as these are the core reasons it was written).

http://stackoverflow.com/questions/871/why-is-git-better-than-subversionhttp://stackoverflow.com/questions/871/why-is-git-better-than-subversion

Basic Commands

● Repository creation/Checkoutgi t i ni t ( I ni t i al i ze a r eposi t or y)

gi t c l one ( svn checkout )

Basic Commands

● Daily routine gi t st at us ( Show t he wor ki ng t r ee st at us )

gi t add ( Add f i l e cont ent s t o t he i ndex )

gi t rm ( Remove f i l es f r om t he wor ki ng t r ee and f r om t he i ndex )

gi t commi t ( Recor d changes t o t he r eposi t or y)

Basic Commands

● Big Brothergi t di f f ( Show changes bet ween commi t s, commi t and wor ki ng t r ee, et c )

gi t bl ame ( Show what r evi s i on and aut hor l ast modi f i ed each l i ne of a f i l e )

gi t bi sect ( Fi nd by bi nar y sear ch t he change t hat i nt r oduced a bug)

Branching & Merging

● branch & merge– Extremely fast

– keep your room clean

– Try new things

Branching & Merging

Branch best practices– Follow Vincent DriessenVincent Driessen's branching model

– Don’t directly work on master or Develop

Typical Workflow

1.New Branch

2.Coding

3.Commit

4.Push

Typical Workflow

1.New Branch

2.Coding

3.Commit

4.Push

$ git branch myNewBranch$ git checkout myNewBranch------------Or------------$ git checkout -b myNewBranch

$ git status# On branch myNewBranch# Untracked files:## MyNewFile.php# MyNewFile2.php

$ git add MyNewFile.php MyNewFile2.php------------Or------------$ git add .

$ git commit -m 'MyCommitMessage'

$ git push origin myNewBranch

Question?