intro to git - cs.uns.edu.armc/disenio/downloads/talleres/2019 - charla git - lisandro perez... ·...

Post on 02-Sep-2019

17 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Intro to GitScott Chacon

What is Git?

Git is an open source, distributed version control system designed for speed

and efficiency

Git is an open source, distributed version control system designed for speed

and efficiency

git-scm.com

Git is an open source, distributed version control

system designed for speed and efficiency

Fully Distributed

(almost) everything is local

which means

which means

everything is fast

which means

everything is fast

every clone is a backup

which means

everything is fast

every clone is a backup

work offline

Git is an open source, distributed version control

system designed for speed and efficiency

Immutable

(almost) never removes data

Snapshots, not Patches

deltastorage

!

!

! !

! ! !

snapshotstorage

deltastorage

!

!

! !

! ! !

snapshotstorage

deltastorage

!

!

! !

! ! !

snapshotstorage

deltastorage

!

!

! !

! ! !

snapshotstorage

deltastorage

!

!

! !

! ! !

snapshotstorage

deltastorage

!

!

! !

! ! !

snapshotstorage

deltastorage

!

!

! !

! ! !

snapshotstorage

deltastorage

!

!

! !

! ! !

snapshotstorage

deltastorage

!

!

! !

! ! !

snapshotstorage

deltastorage

!

!

! !

! ! !

snapshotstorage

deltastorage

!

!

! !

! ! !

snapshotstorage

deltastorage

!

!

! !

! ! !

snapshotstorage

deltastorage

!

!

! !

! ! !

snapshotstorage

deltastorage

!

!

! !

! ! !

snapshotstorage

deltastorage

!

!

! !

! ! !

snapshotstorage

How is this DifferentThan {cvs|svn|p4}?

Git Ist Schnell!

No Network Needed

No Network Needed

Performing a diff

No Network Needed

Performing a diff

Viewing file history

No Network Needed

Performing a diff

Viewing file history

Committing changes

No Network Needed

Performing a diff

Viewing file history

Committing changes

Merging branches

No Network Needed

Performing a diff

Viewing file history

Committing changes

Merging branches

Obtaining any other revision of a file

No Network Needed

Performing a diff

Viewing file history

Committing changes

Merging branches

Obtaining any other revision of a file

Switching branches

jQuery tests

Work Offline

No .svn Directories

Cheap Branching

$ du -h testrepo/ 78M testrepo/$ cd testrepo/$ time git checkout -b newbranchSwitched to a new branch "newbranch"

real 0m0.091suser 0m0.016ssys 0m0.023s

$ du -h testrepo/ 78M testrepo/$ cd testrepo/$ time git checkout -b newbranchSwitched to a new branch "newbranch"

real 0m0.091suser 0m0.016ssys 0m0.023s

$ du -h testrepo/ 78M testrepo/$ cd testrepo/$ time git checkout -b newbranchSwitched to a new branch "newbranch"

real 0m0.091suser 0m0.016ssys 0m0.023s

$ du -h testrepo/ 78M testrepo/$ cd testrepo/$ time git checkout -b newbranchSwitched to a new branch "newbranch"

real 0m0.091suser 0m0.016ssys 0m0.023s

$ du -h testrepo/ 78M testrepo/$ cd testrepo/$ time git checkout -b newbranchSwitched to a new branch "newbranch"

real 0m0.091suser 0m0.016ssys 0m0.023s

$ time cp -Rf testrepo r2

real0m13.684suser0m0.085ssys 0m1.215s

Easy Merging

How Do I Use Git?

First Steps

$ git config --global user.name “Scott Chacon”

$ git config --global user.email “schacon@gmail.com”

Getting A Repo

git init

$ touch hello_world.rb$ git init$ git add .$ git commit -m ‘first commit’

$ touch hello_world.rb$ git init$ git add .$ git commit -m ‘first commit’

$ tree -a.|-- .git| |-- HEAD| |-- branches| |-- config| |-- description| |-- hooks| | |-- post-commit.sample| | |-- post-receive.sample| | |-- ...| | |-- pre-rebase.sample| | `-- update.sample| |-- info| | `-- exclude| |-- objects| | |-- info| | `-- pack| |-- refs| | |-- heads| | `-- tags| `-- remotes`-- hello_world.rb

11 directories, 25 files

$ tree -a.|-- .git| |-- HEAD| |-- branches| |-- config| |-- description| |-- hooks| | |-- post-commit.sample| | |-- post-receive.sample| | |-- ...| | |-- pre-rebase.sample| | `-- update.sample| |-- info| | `-- exclude| |-- objects| | |-- info| | `-- pack| |-- refs| | |-- heads| | `-- tags| `-- remotes`-- hello_world.rb

11 directories, 25 files

$ tree -a.|-- .git| |-- HEAD| |-- branches| |-- config| |-- description| |-- hooks| | |-- post-commit.sample| | |-- post-receive.sample| | |-- ...| | |-- pre-rebase.sample| | `-- update.sample| |-- info| | `-- exclude| |-- objects| | |-- info| | `-- pack| |-- refs| | |-- heads| | `-- tags| `-- remotes`-- hello_world.rb

11 directories, 25 files

git clone

$ git clone

$ git clone git://github.com/schacon/grit.git

$ git clone git://github.com/schacon/grit.git mygrit

$ git clone git://github.com/schacon/grit.git mygritInitialized empty Git repository in /home/schacon/mygrit/.git/remote: Counting objects: 3220, done.remote: Compressing objects: 100% (2093/2093), done.remote: Total 3220 (delta 1134), reused 3149 (delta 1081)Receiving objects: 100% (3220/3220), 1.79 MiB | 357 KiB/s, done.Resolving deltas: 100% (1134/1134), done.

$ git clone git://github.com/schacon/grit.git mygritInitialized empty Git repository in /home/schacon/mygrit/.git/remote: Counting objects: 3220, done.remote: Compressing objects: 100% (2093/2093), done.remote: Total 3220 (delta 1134), reused 3149 (delta 1081)Receiving objects: 100% (3220/3220), 1.79 MiB | 357 KiB/s, done.Resolving deltas: 100% (1134/1134), done.

$ cd mygrit$

$ git clone git://github.com/schacon/grit.git mygritInitialized empty Git repository in /home/schacon/mygrit/.git/remote: Counting objects: 3220, done.remote: Compressing objects: 100% (2093/2093), done.remote: Total 3220 (delta 1134), reused 3149 (delta 1081)Receiving objects: 100% (3220/3220), 1.79 MiB | 357 KiB/s, done.Resolving deltas: 100% (1134/1134), done.

$ cd mygrit$ lsAPI.txt Manifest.txtREADME.txt benchmarks.rb examples libHistory.txt PURE_TODORakefile benchmarks.txt grit.gemspectest$

The Git Directory

git init

$ tree -a.|-- .git| |-- HEAD| |-- branches| |-- config| |-- description| |-- hooks| | |-- post-commit.sample| | |-- post-receive.sample| | |-- ...| | |-- pre-rebase.sample| | `-- update.sample| |-- info| | `-- exclude| |-- objects| | |-- info| | `-- pack| |-- refs| | |-- heads| | `-- tags| `-- remotes`-- hello_world.rb

11 directories, 25 files

$ tree -a.|-- .git| |-- HEAD| |-- branches| |-- config| |-- description| |-- hooks| | |-- post-commit.sample| | |-- post-receive.sample| | |-- ...| | |-- pre-rebase.sample| | `-- update.sample| |-- info| | `-- exclude| |-- objects| | |-- info| | `-- pack| |-- refs| | |-- heads| | `-- tags| `-- remotes`-- hello_world.rb

11 directories, 25 files

Areas of Interest

$ tree -a.|-- .git| |-- HEAD| |-- branches| |-- config| |-- description| |-- hooks| | |-- post-commit.sample| | |-- post-receive.sample| | |-- ...| | |-- pre-rebase.sample| | `-- update.sample| |-- info| | `-- exclude| |-- objects| | |-- info| | `-- pack| |-- refs| | |-- heads| | `-- tags| `-- remotes`-- hello_world.rb

11 directories, 25 files

/etc/gitconfig

/etc/gitconfig

~/.gitconfig

/etc/gitconfig

~/.gitconfig

.git/config

$ tree -a.|-- .git| |-- HEAD| |-- branches| |-- config| |-- description| |-- hooks| | |-- post-commit.sample| | |-- post-receive.sample| | |-- ...| | |-- pre-rebase.sample| | `-- update.sample| |-- info| | `-- exclude| |-- objects| | |-- info| | `-- pack| |-- refs| | |-- heads| | `-- tags| `-- remotes`-- hello_world.rb

11 directories, 25 files

$ tree -a.|-- .git| |-- HEAD| |-- branches| |-- config| |-- description| |-- hooks| | |-- post-commit.sample| | |-- post-receive.sample| | |-- ...| | |-- pre-rebase.sample| | `-- update.sample| |-- info| | `-- exclude| |-- objects| | |-- info| | `-- pack| |-- refs| | |-- heads| | `-- tags| `-- remotes`-- hello_world.rb

11 directories, 25 files

$ tree -a.|-- .git| |-- HEAD| |-- branches| |-- config| |-- description| |-- hooks| | |-- post-commit.sample| | |-- post-receive.sample| | |-- ...| | |-- pre-rebase.sample| | `-- update.sample| |-- info| | `-- exclude| |-- objects| | |-- info| | `-- pack| |-- refs| | |-- heads| | `-- tags| `-- remotes`-- hello_world.rb

11 directories, 25 files

$ touch hello_world.rb$ git init$ git add .$ git commit -m ‘first commit’

$ touch hello_world.rb$ git init$ git add .$ git commit -m ‘first commit’

$ tree -a.|-- .git| |-- COMMIT_EDITMSG| |-- HEAD| |-- branches| |-- config| |-- description| |-- hooks| | |-- applypatch-msg.sample| | `-- update.sample| |-- index| |-- info| | `-- exclude| |-- logs| | |-- HEAD| | `-- refs| | `-- heads| | `-- master| |-- objects| | |-- 32/09658ac8d80bc9726d3a33d77e3dfc5fe6035e| | |-- 53/9cd7886a627841d525a78d45cbc6396be20b41| | |-- e6/9de29bb2d1d6434b8b29ae775ad8c2e48c5391| | |-- info| | `-- pack| |-- refs| | |-- heads| | | `-- master| | `-- tags| `-- remotes`-- hello_world.rb

17 directories, 33 files

$ tree -a.|-- .git| |-- COMMIT_EDITMSG| |-- HEAD| |-- branches| |-- config| |-- description| |-- hooks| | |-- applypatch-msg.sample| | `-- update.sample| |-- index| |-- info| | `-- exclude| |-- logs| | |-- HEAD| | `-- refs| | `-- heads| | `-- master| |-- objects| | |-- 32/09658ac8d80bc9726d3a33d77e3dfc5fe6035e| | |-- 53/9cd7886a627841d525a78d45cbc6396be20b41| | |-- e6/9de29bb2d1d6434b8b29ae775ad8c2e48c5391| | |-- info| | `-- pack| |-- refs| | |-- heads| | | `-- master| | `-- tags| `-- remotes`-- hello_world.rb

17 directories, 33 files

$ tree -a.|-- .git| |-- COMMIT_EDITMSG| |-- HEAD| |-- branches| |-- config| |-- description| |-- hooks| | |-- applypatch-msg.sample| | `-- update.sample| |-- index| |-- info| | `-- exclude| |-- logs| | |-- HEAD| | `-- refs| | `-- heads| | `-- master| |-- objects| | |-- 32/09658ac8d80bc9726d3a33d77e3dfc5fe6035e| | |-- 53/9cd7886a627841d525a78d45cbc6396be20b41| | |-- e6/9de29bb2d1d6434b8b29ae775ad8c2e48c5391| | |-- info| | `-- pack| |-- refs| | |-- heads| | | `-- master| | `-- tags| `-- remotes`-- hello_world.rb

17 directories, 33 files

A Basic Workflow

A Basic Workflow

Edit files

Stage the changes

Review your changes

Commit the changes

working directory

repository

index

git add

git commit

working directory

repository

index

git add

git commit

a working copy of your project

working directory

repository

index

git add

git commit

object database

working directory

repository

index

git add

git commit

“staging”

A Basic Workflow

Edit files

Stage the changes

Review your changes

Commit the changes

$ find ../app.yaml./index.yaml./main.py

$ find ../app.yaml./index.yaml./main.py

$ find ../app.yaml./index.yaml./main.py

#!/usr/bin/env pythonimport wsgiref.handlersfrom google.appengine.ext import webapp

class MainHandler(webapp.RequestHandler):

def get(self): self.response.out.write('Hello world!')

def main(): application = webapp.WSGIApplication([('/', MainHandler)], debug=True) wsgiref.handlers.CGIHandler().run(application)

if __name__ == '__main__': main()~ ~ "main.py" 16L, 402C

$ vim main.py

#!/usr/bin/env pythonimport wsgiref.handlersfrom google.appengine.ext import webapp

class MainHandler(webapp.RequestHandler):

def get(self): self.response.out.write('Hello world!')

def main(): application = webapp.WSGIApplication([('/', MainHandler)], debug=True) wsgiref.handlers.CGIHandler().run(application)

if __name__ == '__main__': main()~ ~ "main.py" 16L, 402C

$ vim main.py

#!/usr/bin/env pythonimport wsgiref.handlersfrom google.appengine.ext import webapp

class MainHandler(webapp.RequestHandler):

def get(self): self.response.out.write('Hello world!')

def main(): application = webapp.WSGIApplication([('/', MainHandler)], debug=True) wsgiref.handlers.CGIHandler().run(application)

if __name__ == '__main__': main()~ ~ "main.py" 16L, 402C

$ vim main.py

#!/usr/bin/env pythonimport wsgiref.handlersfrom google.appengine.ext import webapp

# this program prints out ‘hello world’

class MainHandler(webapp.RequestHandler):

def get(self): self.response.out.write('Hello world!')

def main(): application = webapp.WSGIApplication([('/', MainHandler)], debug=True) wsgiref.handlers.CGIHandler().run(application)

if __name__ == '__main__': main()~ ~ "main.py" 16L, 402C

$ vim main.py

$ git status

$ git status# On branch master# Changed but not updated:# (use "git add <file>..." to update what will be committed)##modified: main.py#no changes added to commit (use "git add" and/or "git commit -a")

$ git status# On branch master# Changed but not updated:# (use "git add <file>..." to update what will be committed)##modified: main.py#no changes added to commit (use "git add" and/or "git commit -a")

$ git status# On branch master# Changed but not updated:# (use "git add <file>..." to update what will be committed)##modified: main.py#no changes added to commit (use "git add" and/or "git commit -a")

$ git status# On branch master# Changed but not updated:# (use "git add <file>..." to update what will be committed)##modified: main.py#no changes added to commit (use "git add" and/or "git commit -a")

$ git status# On branch master# Changed but not updated:# (use "git add <file>..." to update what will be committed)##modified: main.py#no changes added to commit (use "git add" and/or "git commit -a")

$ git status# On branch master# Changed but not updated:# (use "git add <file>..." to update what will be committed)##modified: main.py#no changes added to commit (use "git add" and/or "git commit -a")

$ git status# On branch master# Changed but not updated:# (use "git add <file>..." to update what will be committed)##modified: main.py#no changes added to commit (use "git add" and/or "git commit -a")

STAGED

$ git status# On branch master# Changed but not updated:# (use "git add <file>..." to update what will be committed)##modified: main.py#no changes added to commit (use "git add" and/or "git commit -a")

STAGED

A Basic Workflow

Edit files

Stage the changes

Review your changes

Commit the changes

git add

working directory

repository

index

git add

git commit

working directory

repository

index

git add

git commit

$ git add main.py$ git status# On branch master# Changes to be committed:# (use "git reset HEAD <file>..." to unstage)##modified: main.py#

$ git add main.py$ git status# On branch master# Changes to be committed:# (use "git reset HEAD <file>..." to unstage)##modified: main.py#

$ git add main.py$ git status# On branch master# Changes to be committed:# (use "git reset HEAD <file>..." to unstage)##modified: main.py#

# On branch master# Changes to be committed:# (use "git reset HEAD <file>..." to unstage)##modified: main.py#

$ git add main.py$ git status

# On branch master# Changes to be committed:# (use "git reset HEAD <file>..." to unstage)##modified: main.py#

$ git add main.py$ git status

THAT ARE STAGED

$ vim app.yamlapplication: chaconversion: 1runtime: pythonapi_version: 1

handlers:- url: .* script: main.py~ ~ ~ "app.yaml" 8L, 101C

$ vim app.yamlapplication: chaconversion: 1runtime: pythonapi_version: 1

handlers:- url: .* script: main.py~ ~ ~ "app.yaml" 8L, 101C

$ vim app.yamlapplication: chaconversion: 1runtime: pythonapi_version: 1

handlers:- url: .* script: main.py~ ~ ~ "app.yaml" 8L, 101C

application: chaconversion: 1runtime: pythonapi_version: 1

handlers:- url: .* script: main.py~ ~ ~ "app.yaml" 8L, 101C

$ vim app.yaml

application: chaconversion: 2runtime: pythonapi_version: 1

handlers:- url: .* script: main.py~ ~ ~ "app.yaml" 8L, 101C

$ vim app.yaml

# On branch master# Changes to be committed:# (use "git reset HEAD <file>..." to unstage)## modified: main.py## Changed but not updated:# (use "git add <file>..." to update what will be committed)## modified: app.yaml#

$ git status

# On branch master# Changes to be committed:# (use "git reset HEAD <file>..." to unstage)## modified: main.py## Changed but not updated:# (use "git add <file>..." to update what will be committed)## modified: app.yaml#

$ git status

# On branch master# Changes to be committed:# (use "git reset HEAD <file>..." to unstage)## modified: main.py## Changed but not updated:# (use "git add <file>..." to update what will be committed)## modified: app.yaml#

$ git status

$ vim main.py#!/usr/bin/env pythonimport wsgiref.handlersfrom google.appengine.ext import webapp

# this program prints out ‘hello world’

class MainHandler(webapp.RequestHandler):

def get(self): self.response.out.write('Hello world!')

def main(): application = webapp.WSGIApplication([('/', MainHandler)], debug=True) wsgiref.handlers.CGIHandler().run(application)

if __name__ == '__main__': main()~ ~ "main.py" 16L, 402C

$ vim main.py#!/usr/bin/env pythonimport wsgiref.handlersfrom google.appengine.ext import webapp

# this program prints out ‘hello world’

class MainHandler(webapp.RequestHandler):

def get(self): self.response.out.write('Hello world!')

def main(): application = webapp.WSGIApplication([('/', MainHandler)], debug=True) wsgiref.handlers.CGIHandler().run(application)

if __name__ == '__main__': main()~ ~ "main.py" 16L, 402C

$ vim main.py#!/usr/bin/env pythonimport wsgiref.handlersfrom google.appengine.ext import webapp

# this program prints out ‘hello world’

class MainHandler(webapp.RequestHandler):

def get(self): self.response.out.write('Hello world!')

def main(): application = webapp.WSGIApplication([('/', MainHandler)], debug=True) wsgiref.handlers.CGIHandler().run(application)

if __name__ == '__main__': main()~ ~ "main.py" 16L, 402C

#!/usr/bin/env pythonimport wsgiref.handlersfrom google.appengine.ext import webapp

# this program prints out ‘hello world’

class MainHandler(webapp.RequestHandler):

def get(self): self.response.out.write('Hola world!')

def main(): application = webapp.WSGIApplication([('/', MainHandler)], debug=True) wsgiref.handlers.CGIHandler().run(application)

if __name__ == '__main__': main()~ ~ "main.py" 16L, 402C

$ vim main.py

#!/usr/bin/env pythonimport wsgiref.handlersfrom google.appengine.ext import webapp

# this program prints out ‘hello world’

class MainHandler(webapp.RequestHandler):

def get(self): self.response.out.write('Hola Mundo!')

def main(): application = webapp.WSGIApplication([('/', MainHandler)], debug=True) wsgiref.handlers.CGIHandler().run(application)

if __name__ == '__main__': main()~ ~ "main.py" 16L, 402C

$ vim main.py

# On branch master# Changes to be committed:# (use "git reset HEAD <file>..." to unstage)## modified: main.py## Changed but not updated:# (use "git add <file>..." to update what will be committed)## modified: app.yaml# modified: main.py#

$ git status

# On branch master# Changes to be committed:# (use "git reset HEAD <file>..." to unstage)## modified: main.py## Changed but not updated:# (use "git add <file>..." to update what will be committed)## modified: app.yaml# modified: main.py#

$ git status

# On branch master# Changes to be committed:# (use "git reset HEAD <file>..." to unstage)## modified: main.py## Changed but not updated:# (use "git add <file>..." to update what will be committed)## modified: app.yaml# modified: main.py#

$ git status

# On branch master# Changes to be committed:# (use "git reset HEAD <file>..." to unstage)## modified: main.py## Changed but not updated:# (use "git add <file>..." to update what will be committed)## modified: app.yaml# modified: main.py#

$ git status

Staged

# On branch master# Changes to be committed:# (use "git reset HEAD <file>..." to unstage)## modified: main.py## Changed but not updated:# (use "git add <file>..." to update what will be committed)## modified: app.yaml# modified: main.py#

$ git status

Unstaged

# On branch master# Changes to be committed:# (use "git reset HEAD <file>..." to unstage)## modified: main.py## Changed but not updated:# (use "git add <file>..." to update what will be committed)## modified: app.yaml# modified: main.py#

$ git status

#!/usr/bin/env pythonimport wsgiref.handlersfrom google.appengine.ext import webapp

# this program prints out ‘hello world’

class MainHandler(webapp.RequestHandler):

def get(self): self.response.out.write('Hola Mundo!')

def main(): application = webapp.WSGIApplication([('/' debug=True) wsgiref.handlers.CGIHandler().run(applicat

if __name__ == '__main__': main()

#!/usr/bin/env pythonimport wsgiref.handlersfrom google.appengine.ext import webapp

# this program prints out ‘hello world’

class MainHandler(webapp.RequestHandler):

def get(self): self.response.out.write('Hello World!')

def main(): application = webapp.WSGIApplication([('/' debug=True) wsgiref.handlers.CGIHandler().run(applicat

if __name__ == '__main__': main()

Staged In Working Directory

#!/usr/bin/env pythonimport wsgiref.handlersfrom google.appengine.ext import webapp

# this program prints out ‘hello world’

class MainHandler(webapp.RequestHandler):

def get(self): self.response.out.write('Hola Mundo!')

def main(): application = webapp.WSGIApplication([('/' debug=True) wsgiref.handlers.CGIHandler().run(applicat

if __name__ == '__main__': main()

#!/usr/bin/env pythonimport wsgiref.handlersfrom google.appengine.ext import webapp

# this program prints out ‘hello world’

class MainHandler(webapp.RequestHandler):

def get(self): self.response.out.write('Hello World!')

def main(): application = webapp.WSGIApplication([('/' debug=True) wsgiref.handlers.CGIHandler().run(applicat

if __name__ == '__main__': main()

Staged In Working Directory

You have to stage a file after you edit it

You have to stage a file after you edit it

You have to stage a file after you edit it

$ git status# On branch master# Changes to be committed:# (use "git reset HEAD <file>..." to unstage)## modified: app.yaml# modified: main.py#

$ git add app.yaml main.py

$ git status# On branch master# Changes to be committed:# (use "git reset HEAD <file>..." to unstage)## modified: app.yaml# modified: main.py#

$ git add app.yaml main.py

$ git status# On branch master# Changes to be committed:# (use "git reset HEAD <file>..." to unstage)## modified: app.yaml# modified: main.py#

$ git add app.yaml main.py

A Basic Workflow

Edit files

Stage the changes

Review your changes

Commit the changes

git commit

working directory

repository

index

git add

git commit

working directory

repository

index

git add

git commit

$ git commit

# Please enter the commit message for your changes. Lines starting# with '#' will be ignored, and an empty message aborts the commit.# On branch master# Changes to be committed:# (use "git reset HEAD <file>..." to unstage)## modified: app.yaml# modified: main.py#~ ~ ~ ~ ".git/COMMIT_EDITMSG" 10L, 279C

$ git commit

# Please enter the commit message for your changes. Lines starting# with '#' will be ignored, and an empty message aborts the commit.# On branch master# Changes to be committed:# (use "git reset HEAD <file>..." to unstage)## modified: app.yaml# modified: main.py#~ ~ ~ ~ ".git/COMMIT_EDITMSG" 10L, 279C

$ git commit

# Please enter the commit message for your changes. Lines starting# with '#' will be ignored, and an empty message aborts the commit.# On branch master# Changes to be committed:# (use "git reset HEAD <file>..." to unstage)## modified: app.yaml# modified: main.py#~ ~ ~ ~ ".git/COMMIT_EDITMSG" 10L, 279C

descriptive commit message# Please enter the commit message for your changes. Lines starting# with '#' will be ignored, and an empty message aborts the commit.# On branch master# Changes to be committed:# (use "git reset HEAD <file>..." to unstage)## modified: app.yaml# modified: main.py#~ ~ ~ ~ ".git/COMMIT_EDITMSG" 10L, 279C

$ git commit

descriptive commit message# Please enter the commit message for your changes. Lines starting# with '#' will be ignored, and an empty message aborts the commit.# On branch master# Changes to be committed:# (use "git reset HEAD <file>..." to unstage)## modified: app.yaml# modified: main.py#~ ~ ~ ~ ".git/COMMIT_EDITMSG" 10L, 279C

$ git commit

$ git commitCreated commit 77d3001: descriptive commit message 2 files changed, 4 insertions(+), 2 deletions(-)

A Basic Workflow

Edit files

Stage the changes

Review your changes

Commit the changes

vim / emacs / etc

git add (file)

repo status

git commit

A Basic Workflow

Edit files

Stage the changes

Review your changes

Commit the changes

vim / emacs / etc

git add (file)

repo status

git commit

A Basic Workflow

Edit files

Stage the changes

Review your changes

Commit the changes

vim / emacs / etc

git add (file)

repo status

git commit

A Basic Workflow

Edit files

Stage the changes

Review your changes

Commit the changes

vim / emacs / etc

git add (file)

git status

git commit

A Basic Workflow

Edit files

Stage the changes

Review your changes

Commit the changes

vim / emacs / etc

git add (file)

git status

git commit

cheating...

A Basicerer Workflow

Edit files

Commit the changes

vim / emacs / etc

git commit

A Basicerer Workflow

Edit files

Stage & commit the changes

vim / emacs / etc

git commit -a

A Basicerer Workflow

Edit files

Stage & commit the changes

vim / emacs / etc

git commit -a

What’s going on here?

$ git commitCreated commit 77d3001: descriptive commit message 2 files changed, 4 insertions(+), 2 deletions(-)

$ git commitCreated commit 77d3001: descriptive commit message 2 files changed, 4 insertions(+), 2 deletions(-)

77d3001

77d3001

77d3001a1de6bf8f5e431972fe4d25b01e595c0b

77d3001a1de6bf8f5e431972fe4d25b01e595c0b

77d3001a1de6bf8f5e431972fe4d25b01e595c0b

77d3001a1de6bf8f5e431972fe4d25b01e595c0b

commit size

ae668..

tree

parent

author

committermy commit message goes hereand it is really, really cool

c4ec5

a149eScott

Scott

77d3001a1de6bf8f5e431972fe4d25b01e595c0b

commit size

ae668..

tree

parent

author

committermy commit message goes hereand it is really, really cool

c4ec5

a149eScott

Scott

tree c4ec543b0322744e55c5efc9b6c4e449d398dbffparent a149e2160b3f7573768cdc2fce24d0881f3577e1author Scott Chacon <schacon@gmail.com> 1223402504 -0700committer Scott Chacon <schacon@gmail.com> 1223402504 -0700

descriptive commit message

77d3001a1de6bf8f5e431972fe4d25b01e595c0b

commit size

ae668..

tree

parent

author

committermy commit message goes hereand it is really, really cool

c4ec5

a149eScott

Scott

77d3001a1de6bf8f5e431972fe4d25b01e595c0b

commit size

ae668..

tree

parent

author

committermy commit message goes hereand it is really, really cool

c4ec5

a149eScott

Scott

app.yaml

index.yaml

main.py

./ c4e

03e

1d3

3d5

commit size

ae668..

tree

parent

author

committermy commit message goes hereand it is really, really cool

c4ec5

a149eScott

Scott

app.yaml

index.yaml

main.py

./ c4e

03e

1d3

3d5

commit size

tree

parent

author

committerthis is the previous commitand I am very proud of it

2de54

38defScott

Scott

commit size

ae668..

tree

parent

author

committermy commit message goes hereand it is really, really cool

c4ec5

a149eScott

Scott

app.yaml

index.yaml

main.py

./ c4e

03e

1d3

3d5

commit size

tree

parent

author

committerthis is the previous commitand I am very proud of it

2de54

38defScott

Scott

app.yaml

index.yaml

main.py

./ c4e

03e

1d3

3d5

commit size

ae668..

tree

parent

author

committermy commit message goes hereand it is really, really cool

c4ec5

a149eScott

Scott

app.yaml

index.yaml

main.py

./ c4e

03e

1d3

3d5

commit size

tree

parent

author

committerthis is the previous commitand I am very proud of it

2de54

38defScott

Scott

commit size

tree

parent

author

committerthis is the commit before thatand I'm not sure why

2fe65

90ecdScott

Scott

app.yaml

index.yaml

main.py

./ c4e

03e

1d3

3d5

app.yaml

index.yaml

main.py

./ c4e

03e

1d3

3d5

commit size

tree

parent

author

committerthis is the commit before thatand I'm not sure why

2fe65

90ecdScott

Scott

app.yaml

index.yaml

main.py

./ c4e

03e

1d3

3d5

commit size

ae668..

tree

parent

author

committermy commit message goes hereand it is really, really cool

c4ec5

a149eScott

Scott

app.yaml

index.yaml

main.py

./ c4e

03e

1d3

3d5

commit size

tree

parent

author

committerthis is the previous commitand I am very proud of it

2de54

38defScott

Scott

commit size

tree

parent

author

committerthis is the commit before thatand I'm not sure why

2fe65

90ecdScott

Scott

app.yaml

index.yaml

main.py

./ c4e

03e

1d3

3d5

app.yaml

index.yaml

main.py

./ c4e

03e

1d3

3d5

commit size

tree

parent

author

committerthis is the commit before thatand I'm not sure why

2fe65

90ecdScott

Scott

app.yaml

index.yaml

main.py

./ c4e

03e

1d3

3d5

48e 77da1438d

c4e

3d5

1d3

03e

f46

23f

30e

67e

32a

5b1

commit size

ae668..

tree

parent

author

committermy commit message goes hereand it is really, really cool

c4ec5

a149eScott

Scott

app.yaml

index.yaml

main.py

./ c4e

03e

1d3

3d5

commit size

tree

parent

author

committerthis is the previous commitand I am very proud of it

2de54

38defScott

Scott

commit size

tree

parent

author

committerthis is the commit before thatand I'm not sure why

2fe65

90ecdScott

Scott

app.yaml

index.yaml

main.py

./ c4e

03e

1d3

3d5

app.yaml

index.yaml

main.py

./ c4e

03e

1d3

3d5

commit size

tree

parent

author

committerthis is the commit before thatand I'm not sure why

2fe65

90ecdScott

Scott

app.yaml

index.yaml

main.py

./ c4e

03e

1d3

3d5

48e

77d

a14

38d

c4e

3d51d3

03e

f46

23f 30e

67e

32a

5b1

Repository

3d4

03e

ae6

5b1

1d3

c36

f46

23f

6fe

30e

67e

32a

ffe

38d

5b1

1d3

254

a14

d23

2d3

48e

735

de3

c4ec4e

77d

3d5

Repository

3d4

03e

ae6

5b1

1d3

c36

f46

23f

6fe

30e

67e

32a

ffe

38d

5b1

1d3

254

a14

d23

2d3

48e

735

de3

c4ec4e

77d

3d5

git checkout ae635

Repository

3d4

03e

ae6

5b1

1d3

c36

f46

23f

6fe

30e

67e

32a

ffe

38d

5b1

1d3

254

a14

d23

2d3

48e

735

de3

c4ec4e

77d

3d5

git checkout ae635

Working DirectoryIndex

Rakefile

README

simplegit.rb

./

lib/

./Rakefile

./README

./lib/simplegit.rb

./

./lib/ c36

3d4

03e

5b1

1d3

Repository

3d4

03e

ae6

5b1

1d3

c36

f46

23f

6fe

30e

67e

32a

ffe

38d

5b1

1d3

254

a14

d23

2d3

48e

735

de3

c4ec4e

77d

3d5

Repository

3d4

03e

ae6

5b1

1d3

c36

f46

23f

6fe

30e

67e

32a

ffe

38d

5b1

1d3

254

a14

d23

2d3

48e

735

de3

c4ec4e

77d

3d5

Working DirectoryIndex

Rakefile

README

simplegit.rb

./

lib/

./Rakefile

./README

./lib/simplegit.rb

./

./lib/ c36

3d4

03e

5b1

1d3

Repository

3d4

03e

ae6

5b1

1d3

c36

f46

23f

6fe

30e

67e

32a

ffe

38d

5b1

1d3

254

a14

d23

2d3

48e

735

de3

c4ec4e

77d

3d5

Working DirectoryIndex

Rakefile

README

simplegit.rb

./

lib/

./Rakefile

./README

./lib/simplegit.rb

./

./lib/ c36

3d4

03e

5b1

1d3

Repository

3d4

03e

ae6

5b1

1d3

c36

f46

23f

6fe

30e

67e

32a

ffe

38d

5b1

1d3

254

a14

d23

2d3

48e

735

de3

c4ec4e

77d

3d5

Working DirectoryIndex

Rakefile

README

simplegit.rb

./

lib/

./Rakefile

./README

./lib/simplegit.rb

./

./lib/ c36

3d4

03e

5b1

1d3

Repository

3d4

03e

ae6

5b1

1d3

c36

f46

23f

6fe

30e

67e

32a

ffe

38d

5b1

1d3

254

a14

d23

2d3

48e

735

de3

c4ec4e

77d

3d5

Working DirectoryIndex

Rakefile

README

simplegit.rb

./

lib/

./Rakefile

./README

./lib/simplegit.rb

./

./lib/ c36

3d4

03e

5b1

1d3

git add

Repository

3d4

03e

ae6

5b1

1d3

c36

f46

23f

6fe

30e

67e

32a

ffe

38d

5b1

1d3

254

a14

d23

2d3

48e

735

de3

c4ec4e

77d

3d5

Working DirectoryIndex

Rakefile

README

simplegit.rb

./

lib/

./Rakefile

./README

./lib/simplegit.rb

./

./lib/ c36

3d4

03e

5b1

1d3

git add

34f

Repository

3d4

03e

ae6

5b1

1d3

c36

f46

23f

6fe

30e

67e

32a

ffe

38d

5b1

1d3

254

a14

d23

2d3

48e

735

de3

c4ec4e

77d

3d5

Working DirectoryIndex

Rakefile

README

simplegit.rb

./

lib/

./Rakefile

./README

./lib/simplegit.rb

./

./lib/ c36

3d4

03e

5b1

1d3

git commit

34f

a083da34f

ae9

Repository

3d4

03e

ae6

5b1

1d3

c36

f46

23f

6fe

30e

67e

32a

ffe

38d

5b1

1d3

254

a14

d23

2d3

48e

735

de3

c4ec4e

77d

3d5

Working DirectoryIndex

Rakefile

README

simplegit.rb

./

lib/

./Rakefile

./README

./lib/simplegit.rb

./

./lib/ c36

3d4

03e

5b1

1d334f

a083da34f

ae9

Repository

3d4

03e

ae6

5b1

1d3

c36

f46

23f

6fe

30e

67e

32a

ffe

38d

5b1

1d3

254

a14

d23

2d3

48e

735

de3

c4ec4e

77d

3d5

Working DirectoryIndex

Rakefile

README

simplegit.rb

./

lib/

./Rakefile

./README

./lib/simplegit.rb

./

./lib/ c36

3d4

03e

5b1

1d334f

a083da34f

ae9

object model

blob

commit

tree

C1}

object model

blob

commit

tree

C1}directory list

file contents

pointer to a snapshot

object model

blob

commit

tree

C1}directory list

file contents

pointer to a snapshot

Branching and Merging

branches

brancheslightweight, movablepointers to a commit

C1

branch

branching

git branch

git checkout

C1

master

C0

C2 C3

experiment

HEAD

default

C1

master

C0

C2 C3

experimentC1

master

C0

C2 C3

C4

experiment

C5

T1

git branch experiment

HEAD

default

C1

master

C0

C2 C3

experimentC1

master

C0

C2 C3

C4

experiment

C5

T1

git branch experiment

HEAD

default

C1

master

C0

C2 C3

experimentC1

master

C0

C2 C3

C4

experiment

C5

T1

HEAD

$ git branch* default experiment

default

C1

master

C0

C2 C3

experimentC1

master

C0

C2 C3

C4

experiment

C5

T1

HEAD

$ git branch* default experiment

default

C1

master

C0

C2 C3

experimentC1

master

C0

C2 C3

C4

experiment

C5

T1

git checkout experiment

HEAD

default

C1

master

C0

C2 C3

experiment

C1

master

C0

C2 C3

C4

experiment

C5

T1

git commit

HEAD

default

C1

master

C0

C2 C3

experiment

C1

master

C0

C2 C3

C4

experiment

C5

T1

git commit

HEAD

default

C1

master

C0

C2 C3

experiment

C1

master

C0

C2 C3

C4

experiment

C5

T1

git commit

HEAD

default

C1

master

C0

C2 C3

experiment

C1

master

C0

C2 C3

C4

experiment

C5

T1

git commitgit commit

HEAD

default

C1

master

C0

C2 C3

experiment

C1

master

C0

C2 C3

C4

experiment

C5

T1

HEAD

git checkout defaultdefault

C1

master

C0

C2 C3

experiment

C1

master

C0

C2 C3

C4

experiment

C5

T1

HEAD

git checkout defaultdefault

C1

master

C0

C2 C3

C4

experiment

C5

T1

C1

master

C0

C2 C3

C4

experiment

C5

T1git commit

HEAD

default

C1

master

C0

C2 C3

C4

experiment

C5

T1

C1

master

C0

C2 C3

C4

experiment

C5

T1git commit

HEAD

default

C1

master

C0

C2 C3

C4

experiment

C5

T1

C1

master

C0

C2 C3

C4

experiment

C5

T1git commit

HEAD

default

C1

master

C0

C2 C3

C4

experiment

C5

T1

git checkout experimentgit commit

HEAD

default

merging

git merge

C1

master

C0

C2 C3

C4

experiment

C5

T1

HEAD

default

C1

master

C0

C2 C3

C4

experiment

C5

T1

HEAD

git checkout default

default

C1C0

C2 C3

C4

experiment

C5

C6

masterT1

git checkout defaultgit merge experiment

HEAD

default

C1C0

C2 C3

C4

experiment

C5

C6

masterT1

git checkout defaultgit merge experiment

HEAD

default

C1C0

C2 C3

C4

C5

C6

C7

C8

default

experiment

HEADgit checkout experiment

C1C0

C2 C3

C4

C5

C6

C7

C8

default

experiment

HEADgit commit

C1C0

C2 C3

C4

C5

C6

C7

C8

default

experiment

HEAD

git checkout default

C1C0

C2 C3

C4

C5

C6

C7

C8

default

experiment

HEAD

git merge experiment

Hot 3 Way Merge

Action

C1

master

C0

C2 C3

C4

experiment

C5

C1

master

C0

C2 C3

C4

experiment

C5

C1C0

C2 C3

C4

C5

C6

C7

C1C0

C2 C3

C4

C5

C6

C7

C1C0

C2 C3

C4

C5

C6

C7

Remotes

Distributed Workflow

public repo

local repo

local repo

public repo

internet

A B C

public repo

local repo

local repo

public repo

git push(ssh)

internet

A B C

A B C

public repo

local repo

local repo

public repo

git push(ssh)

git fetch(git)

internet

A B C

A B C

A B C

public repo

local repo

local repo

public repo

git push(ssh)

git fetch(git)

internet

A B C

A B C

A B C

D E F git commit

public repo

local repo

local repo

public repo

git push(ssh)

git fetch(git)

git push(ssh)

internet

A B C

A B C

A B C

D E F

A B C

D E F

public repo

local repo

local repo

public repo

git fetch(http)

git push(ssh)

git fetch(git)

git push(ssh)

internet

A B C

A B C

A B C

D E F

A B C

D E F

D E F

public repo

local repo

local repo

public repo

git fetch(http)

git push(ssh)

git fetch(git)

git push(ssh)

internet

A B C

A B C

A B C

D E F

A B C

D E F

D E FD E F

Multiple Remotes

developernick

developerjessica

my repo5ec

e4a4a7ce0 master

developernick

developerjessica

my repo5ec

e4a4a7ce0 master

commit

developernick

developerjessica

my repo5ec

e4a4a7ce0 master

tree

developernick

developerjessica

my repo5ec

e4a4a7ce0 master

blobs

schacon/project

developernick

developerjessica

"public"

my repo5ec

e4a4a7ce0 master

git push public

public/master

5ece4a

4a7ce0

schacon/project

developerjessica

"public"

my repo5ec

e4a4a7ce0 master

git clone (url)

public/master

5ece4a

4a7ce0

5ece4a

4a7ce0developer

nick

schacon/project

developerjessica

"public"

my repo5ec

e4a4a7ce0 master

git commit

public/master

5ece4a

4a7ce0

5ece4a

4a7ce0developer

nickc12ec524f

schacon/project

"public"

my repo5ec

e4a4a7ce0 master

public/master

5ece4a

4a7ce0

5ece4a

4a7ce0developer

nickc12ec524f git clone (url)

5ece4a

4a7ce0developer

jessica

schacon/project

"public"

my repo5ec

e4a4a7ce0 master

public/master

5ece4a

4a7ce0

5ece4a

4a7ce0developer

nickc12ec524f

5ece4a

4a7ce0developer

jessica2fbdf74ea

a09git commit

schacon/project

"public"

my repo5ec

e4a4a7ce0 master

public/master

5ece4a

4a7ce0

5ece4a

4a7ce0developer

nickc12ec524f

5ece4a

4a7ce0developer

jessica2fbdf74ea

a09git push

5ece4a

4a7ce0nickh/project

c12ec524f

5ece4a

4a7ce0jessica/project

2fbdf74eaa09

schacon/project

"public"

my repo5ec

e4a4a7ce0 master

public/master

5ece4a

4a7ce0

5ece4a

4a7ce0developer

nickc12ec524f

5ece4a

4a7ce0developer

jessica2fbdf74ea

a09

git remote add nick git://github.com/nickh/project.git

5ece4a

4a7ce0nickh/project

c12ec524f

5ece4a

4a7ce0jessica/project

2fbdf74eaa09"nick"

git remote add nick git://github.com/nickh/project.git

schacon/project

"public"

my repo5ec

e4a4a7ce0 master

public/master

5ece4a

4a7ce0

5ece4a

4a7ce0developer

nickc12ec524f

5ece4a

4a7ce0developer

jessica2fbdf74ea

a09

git remote add nick git://github.com/nickh/project.git

5ece4a

4a7ce0nickh/project

c12ec524f

5ece4a

4a7ce0jessica/project

2fbdf74eaa09"nick"“nick”

git remote add nick git://github.com/nickh/project.git

schacon/project

"public"

my repo5ec

e4a4a7ce0 master

public/master

5ece4a

4a7ce0

5ece4a

4a7ce0developer

nickc12ec524f

5ece4a

4a7ce0developer

jessica2fbdf74ea

a09

git remote add jess git://github.com/jessica/project.git

5ece4a

4a7ce0nickh/project

c12ec524f

5ece4a

4a7ce0jessica/project

2fbdf74eaa09"nick" "jess"

git remote add jess git://github.com/jessica/project.git

schacon/project

"public"

my repo5ec

e4a4a7ce0 master

public/master

5ece4a

4a7ce0

5ece4a

4a7ce0developer

nickc12ec524f

5ece4a

4a7ce0developer

jessica2fbdf74ea

a09

git remote add jess git://github.com/jessica/project.git

5ece4a

4a7ce0nickh/project

c12ec524f

5ece4a

4a7ce0jessica/project

2fbdf74eaa09"nick" "jess"

git remote add jess git://github.com/jessica/project.git

“jess”

schacon/project

"public"

my repo5ec

e4a4a7ce0 master

public/master

5ece4a

4a7ce0

5ece4a

4a7ce0developer

nickc12ec524f

5ece4a

4a7ce0developer

jessica2fbdf74ea

a09

git remote add jess git://github.com/jessica/project.git

5ece4a

4a7ce0nickh/project

c12ec524f

5ece4a

4a7ce0jessica/project

2fbdf74eaa09"nick" "jess"

schacon/project

"public"

my repo5ec

e4a4a7ce0 master

public/master

5ece4a

4a7ce0

5ece4a

4a7ce0developer

nickc12ec524f

5ece4a

4a7ce0developer

jessica2fbdf74ea

a09

git fetch nick

5ece4a

4a7ce0nickh/project

c12ec524f

5ece4a

4a7ce0jessica/project

2fbdf74eaa09"nick" "jess"

c12ec524f nick/master

git fetch nick

schacon/project

"public"

my repo5ec

e4a4a7ce0 master

public/master

5ece4a

4a7ce0

5ece4a

4a7ce0developer

nickc12ec524f

5ece4a

4a7ce0developer

jessica2fbdf74ea

a09

git remote add jess git://github.com/jessica/project.git

5ece4a

4a7ce0nickh/project

c12ec524f

5ece4a

4a7ce0jessica/project

2fbdf74eaa09"nick" "jess"

schacon/project

"public"

my repo5ec

e4a4a7ce0 master

public/master

5ece4a

4a7ce0

5ece4a

4a7ce0developer

nickc12ec524f

5ece4a

4a7ce0developer

jessica2fbdf74ea

a09

git fetch nick

5ece4a

4a7ce0nickh/project

c12ec524f

5ece4a

4a7ce0jessica/project

2fbdf74eaa09"nick" "jess"

c12ec524f nick/master

git fetch nick

schacon/project

"public"

my repo5ec

e4a4a7ce0 master

public/master

5ece4a

4a7ce0

5ece4a

4a7ce0developer

nickc12ec524f

5ece4a

4a7ce0developer

jessica2fbdf74ea

a09

git fetch nick

5ece4a

4a7ce0nickh/project

c12ec524f

5ece4a

4a7ce0jessica/project

2fbdf74eaa09"nick" "jess"

c12ec524f nick/master

schacon/project

"public"

my repo5ec

e4a4a7ce0 master

public/master

5ece4a

4a7ce0

5ece4a

4a7ce0developer

nickc12ec524f

5ece4a

4a7ce0developer

jessica2fbdf74ea

a09

git remote add jess git://github.com/jessica/project.git

5ece4a

4a7ce0nickh/project

c12ec524f

5ece4a

4a7ce0jessica/project

2fbdf74eaa09"nick" "jess"

git fetch jess

schacon/project

"public"

my repo5ec

e4a4a7ce0 master

public/master

5ece4a

4a7ce0

5ece4a

4a7ce0developer

nickc12ec524f

5ece4a

4a7ce0developer

jessica2fbdf74ea

a09

git fetch jess

5ece4a

4a7ce0nickh/project

c12ec524f

5ece4a

4a7ce0jessica/project

2fbdf74eaa09"nick" "jess"

ec524f nick/master

2fbdf74eaa09

jess/masterc12

schacon/project

"public"

my repo5ec

e4a4a7ce0 master

public/master

5ece4a

4a7ce0

5ece4a

4a7ce0developer

nickc12ec524f

5ece4a

4a7ce0developer

jessica2fbdf74ea

a09

git fetch nick

5ece4a

4a7ce0nickh/project

c12ec524f

5ece4a

4a7ce0jessica/project

2fbdf74eaa09"nick" "jess"

c12ec524f nick/master

schacon/project

"public"

my repo5ec

e4a4a7ce0 master

public/master

5ece4a

4a7ce0

5ece4a

4a7ce0developer

nickc12ec524f

5ece4a

4a7ce0developer

jessica2fbdf74ea

a09

git remote add jess git://github.com/jessica/project.git

5ece4a

4a7ce0nickh/project

c12ec524f

5ece4a

4a7ce0jessica/project

2fbdf74eaa09"nick" "jess"

git fetch jess

schacon/project

"public"

my repo5ec

e4a4a7ce0 master

public/master

5ece4a

4a7ce0

5ece4a

4a7ce0developer

nickc12ec524f

5ece4a

4a7ce0developer

jessica2fbdf74ea

a09

git fetch jess

5ece4a

4a7ce0nickh/project

c12ec524f

5ece4a

4a7ce0jessica/project

2fbdf74eaa09"nick" "jess"

ec524f nick/master

2fbdf74eaa09

jess/masterc12

schacon/project

"public"

my repo5ec

e4a4a7ce0 master

public/master

5ece4a

4a7ce0

5ece4a

4a7ce0developer

nickc12ec524f

5ece4a

4a7ce0developer

jessica2fbdf74ea

a09

git fetch nick

5ece4a

4a7ce0nickh/project

c12ec524f

5ece4a

4a7ce0jessica/project

2fbdf74eaa09"nick" "jess"

c12ec524f nick/master

schacon/project

"public"

my repo5ec

e4a4a7ce0 master

public/master

5ece4a

4a7ce0

5ece4a

4a7ce0developer

nickc12ec524f

5ece4a

4a7ce0developer

jessica2fbdf74ea

a09

git fetch jess

5ece4a

4a7ce0nickh/project

c12ec524f

5ece4a

4a7ce0jessica/project

2fbdf74eaa09"nick" "jess"

ec524f nick/master

2fbdf74eaa09

jess/masterc12

schacon/project

"public"

my repo5ec

e4a4a7ce0

master

public/master

5ece4a

4a7ce0

5ece4a

4a7ce0developer

nickc12ec524f

5ece4a

4a7ce0developer

jessica2fbdf74ea

a09

5ece4a

4a7ce0nickh/project

c12ec524f

5ece4a

4a7ce0jessica/project

2fbdf74eaa09"nick" "jess"

ec524f nick/master

2fbdf74eaa09

jess/masterc12

b3bc63

git merge nick jess

schacon/project

"public"

my repo5ec

e4a4a7ce0

master

public/master

5ece4a

4a7ce0

5ece4a

4a7ce0developer

nickc12ec524f

5ece4a

4a7ce0developer

jessica2fbdf74ea

a09

git push public

5ece4a

4a7ce0nickh/project

c12ec524f

5ece4a

4a7ce0jessica/project

2fbdf74eaa09"nick" "jess"

ec524f nick/master

2fbdf74eaa09

jess/masterc12

b3bc63

e4aec524f

2fbdf74eaa09

c12

b3bc63

schacon/project

"public"

my repo5ec

e4a4a7ce0

master

public/master

5ece4a

4a7ce0

5ece4a

4a7ce0developer

nickc12ec524f

5ece4a

4a7ce0developer

jessica2fbdf74ea

a09

5ece4a

4a7ce0nickh/project

c12ec524f

5ece4a

4a7ce0jessica/project

2fbdf74eaa09"nick" "jess"

ec524f nick/master

2fbdf74eaa09

jess/masterc12

b3bc63

e4aec524f

2fbdf74eaa09

c12

b3bc63

schacon/project

"public"

my repo5ec

e4a4a7ce0

master

public/master

5ece4a

4a7ce0

5ece4a

4a7ce0developer

nickc12ec524f

5ece4a

4a7ce0developer

jessica2fbdf74ea

a09

5ece4a

4a7ce0nickh/project

c12ec524f

5ece4a

4a7ce0jessica/project

2fbdf74eaa09"nick" "jess"

ec524f nick/master

2fbdf74eaa09

jess/masterc12

b3bc63

e4aec524f

2fbdf74eaa09

c12

b3bc63

schacon/project

"public"

my repo5ec

e4a4a7ce0

master

public/master

5ece4a

4a7ce0

5ece4a

4a7ce0developer

nickc12ec524f

5ece4a

4a7ce0developer

jessica2fbdf74ea

a09

5ece4a

4a7ce0nickh/project

c12ec524f

5ece4a

4a7ce0jessica/project

2fbdf74eaa09"nick" "jess"

ec524f nick/master

2fbdf74eaa09

jess/masterc12

b3bc63

e4aec524f

2fbdf74eaa09

c12

b3bc63

schacon/project

"public"

my repo5ec

e4a4a7ce0

master

public/master

5ece4a

4a7ce0

5ece4a

4a7ce0developer

nickc12ec524f

5ece4a

4a7ce0developer

jessica2fbdf74ea

a09

5ece4a

4a7ce0nickh/project

c12ec524f

5ece4a

4a7ce0jessica/project

2fbdf74eaa09"nick" "jess"

ec524f nick/master

2fbdf74eaa09

jess/masterc12

b3bc63

e4aec524f

2fbdf74eaa09

c12

b3bc63

Remotes Are Branches

C0

default

scott jessica

C1

C0

default

scott jessica

C1

C0

scott/default default

C1

C0

default

scott jessica

C1

C0

scott/default default

C1

git clone

C0

default

scott jessica

C1

C0

scott/default default

C1

C0

default

scott jessica

C1

C0

scott/default default

C1

C0

default

scott jessica

C1 C1

C0

scott/default

default

C2

C3

C4

C0

default

scott jessica

C1 C1

C0

scott/default

default

C2

C3

C4

C0

default

scott jessica

C1 C1

C0

scott/default

default

C2

C3

C4

C0

default

scott

C1

C5

C6

C7

jessica

C1

C0

scott/default

default

C2

C3

C4

C0

default

scott

C1

C5

C6

C7

jessica

C1

C0

scott/default

default

C2

C3

C4

C0

default

scott jessica

C1

C0

scott/default default

C2

C3

C4

C1

C5

C6

C7

C5

C6

C7

C0

default

scott jessica

C1

C0

scott/default default

C2

C3

C4

C1

C5

C6

C7

C5

C6

C7

experiment

C8

C9

C0

default

scott jessica

C1

C0

scott/default default

C2

C3

C4

C1

C5

C6

C7

C5

C6

C7

experiment

C8

C9

C0

default

scott jessica

C1

C0

scott/default default

C2

C3

C4

C1

C5

C6

C7

C5

C6

C7

experiment

C8

C9

git merge experiment

git merge scott/default

C0

default

scott jessica

C1

C0

scott/default default

C2

C3

C4

C1

C5

C6

C7

C5

C6

C7

experiment

C8

C9

C0

default

scott jessica

C1

C0

scott/default default

C2

C3

C4

C1

C5

C6

C7

C5

C6

C7

experiment

C8

C9

a “remote” branch is simply alocal pointer to the last known

state of another repository

Why is this cool?

non-linear development

• clone the code that is in production

• clone the code that is in production

• create a branch for issue #53 (iss53)

• clone the code that is in production

• create a branch for issue #53 (iss53)

• work for 10 minutes

• clone the code that is in production

• create a branch for issue #53 (iss53)

• work for 10 minutes

• someone asks for a hotfix for issue #102

• clone the code that is in production

• create a branch for issue #53 (iss53)

• work for 10 minutes

• someone asks for a hotfix for issue #102

• checkout ‘production’

• clone the code that is in production

• create a branch for issue #53 (iss53)

• work for 10 minutes

• someone asks for a hotfix for issue #102

• checkout ‘production’

• create a branch (iss102)

• clone the code that is in production

• create a branch for issue #53 (iss53)

• work for 10 minutes

• someone asks for a hotfix for issue #102

• checkout ‘production’

• create a branch (iss102)

• fix the issue

• clone the code that is in production

• create a branch for issue #53 (iss53)

• work for 10 minutes

• someone asks for a hotfix for issue #102

• checkout ‘production’

• create a branch (iss102)

• fix the issue

• checkout ‘production’, merge ‘iss102’

• clone the code that is in production

• create a branch for issue #53 (iss53)

• work for 10 minutes

• someone asks for a hotfix for issue #102

• checkout ‘production’

• create a branch (iss102)

• fix the issue

• checkout ‘production’, merge ‘iss102’

• push ‘production’

• clone the code that is in production

• create a branch for issue #53 (iss53)

• work for 10 minutes

• someone asks for a hotfix for issue #102

• checkout ‘production’

• create a branch (iss102)

• fix the issue

• checkout ‘production’, merge ‘iss102’

• push ‘production’

• etc

C0

production

C1origin/master

git clone

C0

production

C1origin/master iss53

git checkout -b iss53

C0

production

C1origin/master

iss53

C2

git commit

C0

production

C1origin/master

iss53

C2

C3

git commit

C0

production

C1origin/master

iss53

C2

C3

iss102

git checkout productiongit checkout -b iss102

C0

production

C1origin/master

iss53

C2

C3 iss102

C4

git commit

C0

production

C1origin/master

iss53

C2

C3

iss102 C4

git checkout productiongit merge iss102

C0

production

C1

origin/master

iss53

C2

C3

C4

git push

C0

production

C1

origin/master

iss53

C2

C3

C4

C5

git checkout iss53git commit

C0

production

C1

origin/master

iss53

C2

C3

C4

C5

iss53v2

git checkout productiongit checkout -b iss53v2

C0

production

C1

origin/master

iss53

C2

C3

C4

C5

iss53v2

C6

C7

git commitgit commit

try out an idea

isolate work units

long running topics

pain freecontext switching

Changes

deltastorage

!

!

! !

! ! !

snapshotstorage

deltastorage

!

!

! !

! ! !

snapshotstorage

deltastorage

!

!

! !

! ! !

snapshotstorage

git diff

What is not yet staged?

git diff

git diff

working directory

repository

index

What is staged?

git diff --cached

git diff --cached

working directory

repository

index

Unified Diff

git diff > change.patch

git diff > change.patch

patch -p1 < change.patch

git diff > change.patch

patch -p1 < change.patch

git apply change.patchor

History

git log

What am I about to submit?

git log [branch]..

git log origin/master..

git log origin/master..

what you’ve committed that isn’t pushed yet

Git Help

git [command] --help

git help [command]

git-scm.com

git-scm.com

Basic Commands Review

12

git init

12

git init

git clone

12

git init

git clone

git add 12

git init

git clone

git add

git commit 12

git init

git clone

git add

git commit

git branch12

git init

git clone

git add

git commit

git branch

git checkout

12

git init

git clone

git add

git commit

git branch

git checkout

git merge

12

git init

git clone

git add

git commit

git branch

git checkout

git merge

git remote

12

git init

git clone

git add

git commit

git branch

git checkout

git merge

git remote

git fetch 12

git init

git clone

git add

git commit

git branch

git checkout

git merge

git remote

git fetch

git push 12

git init

git clone

git add

git commit

git branch

git checkout

git merge

git remote

git fetch

git push

git diff12

git init

git clone

git add

git commit

git branch

git checkout

git merge

git remote

git fetch

git push

git diff

git log

12

that’s it!

Resources

Resources

git-scm.com

Resources

git-scm.com

gitcasts.com

Resources

git-scm.com

gitcasts.com

learn.github.com

Resources

git-scm.com

gitcasts.com

learn.github.com

#git / #github on IRC

Resources

git-scm.com

gitcasts.com

learn.github.com

#git / #github on IRC

peepcode - git book and screencast

top related