523
Getting Git Scott Chacon

Using Git to Manage and Deploy Rails Apps

Embed Size (px)

DESCRIPTION

Git is a stupid content tracker used primarily as a distributed source code management system that is beginning to get a lot of use in the Rails community, including a new Capistrano SCM module, a new Peepcast episode focused on it, and the Rubinius project switching to it.This talk will first demonstrate how Git works at a technical level, including descriptions of the object database, the index file, the working directory, the main Git object types and the plumbing toolkit. We will first show how Git is primarily a tree history storage and directory content management system, and then demonstrate how an SCM is built on top of that.It will then cover how you can use Git to manage a software project with a distributed team. This will cover creating a new Git repository, exporting public or external repositories, branching and merging, pushing and pulling between users repositories, and tagging. We will also go over how to use Git to work with SVN projects and how to convert an SVN project to Git.Lastly, we will go over how to deploy a Rails app with Capistrano’s new Git SCM module. Since Capistrano 2.1, Git is a supported SCM, and this talk will cover how to set it up and what options are available.

Citation preview

Page 1: Using Git to Manage and Deploy Rails Apps

Getting GitScott Chacon

Page 2: Using Git to Manage and Deploy Rails Apps

2m Who is Scott?

What is Git?

How Does Git Work?

How Do I Use Git?

2m This Slide

3m

20m

12m

How Do I Deploy with Git?4m

Where Can I Learn More?2m

75%

35 min

15%

6 min

10%

4 min

Page 3: Using Git to Manage and Deploy Rails Apps

2m Who is Scott?

What is Git?

How Does Git Work?

How Do I Use Git?

2m This Slide

3m

20m

12m

How Do I Deploy with Git?4m

Where Can I Learn More?2m

75%

35 min

15%

6 min

10%

4 min

2m This Slide10%

4 min

Page 4: Using Git to Manage and Deploy Rails Apps

2m Who is Scott?

What is Git?

How Does Git Work?

How Do I Use Git?

2m This Slide

3m

20m

12m

How Do I Deploy with Git?4m

Where Can I Learn More?2m

75%

35 min

15%

6 min

10%

4 min2m Who is Scott?

10%

4 min

Page 5: Using Git to Manage and Deploy Rails Apps

2m Who is Scott?

What is Git?

How Does Git Work?

How Do I Use Git?

2m This Slide

3m

20m

12m

How Do I Deploy with Git?4m

Where Can I Learn More?2m

75%

35 min

15%

6 min

10%

4 min

75%

35 min

3m What is Git?

Page 6: Using Git to Manage and Deploy Rails Apps

2m Who is Scott?

What is Git?

How Does Git Work?

How Do I Use Git?

2m This Slide

3m

20m

12m

How Do I Deploy with Git?4m

Where Can I Learn More?2m

75%

35 min

15%

6 min

10%

4 min

75%

35 min

20m How Does Git Work?

Page 7: Using Git to Manage and Deploy Rails Apps

2m Who is Scott?

What is Git?

How Does Git Work?

How Do I Use Git?

2m This Slide

3m

20m

12m

How Do I Deploy with Git?4m

Where Can I Learn More?2m

75%

35 min

15%

6 min

10%

4 min

75%

35 min

12m How Do I Use Git?

Page 8: Using Git to Manage and Deploy Rails Apps

2m Who is Scott?

What is Git?

How Does Git Work?

How Do I Use Git?

2m This Slide

3m

20m

12m

How Do I Deploy with Git?4m

Where Can I Learn More?2m

75%

35 min

15%

6 min

10%

4 min

4m How Do I Deploy with Git?15%

6 min

Page 9: Using Git to Manage and Deploy Rails Apps

2m Who is Scott?

What is Git?

How Does Git Work?

How Do I Use Git?

2m This Slide

3m

20m

12m

How Do I Deploy with Git?4m

Where Can I Learn More?2m

75%

35 min

15%

6 min

10%

4 min

2m Where Can I Learn More?

15%

6 min

Page 10: Using Git to Manage and Deploy Rails Apps

Who Is Scott?Introducing myself...

Page 11: Using Git to Manage and Deploy Rails Apps

2m Who is Scott?

What is Git?

How Does Git Work?

How Do I Use Git?

2m This Slide

3m

20m

12m

How Do I Deploy with Git?4m

Where Can I Learn More?2m

75%

35 min

15%

6 min

10%

4 min2m Who is Scott?

10%

4 min

Page 12: Using Git to Manage and Deploy Rails Apps

Scott Anthony Chacon

Page 13: Using Git to Manage and Deploy Rails Apps

github.com/schacon

Page 14: Using Git to Manage and Deploy Rails Apps
Page 15: Using Git to Manage and Deploy Rails Apps

www.gitcasts.com

Page 16: Using Git to Manage and Deploy Rails Apps
Page 17: Using Git to Manage and Deploy Rails Apps

RailsGitXen3D CamerasHuge Flat Screensjepoirrier@flickr

Page 18: Using Git to Manage and Deploy Rails Apps
Page 19: Using Git to Manage and Deploy Rails Apps

me

Page 20: Using Git to Manage and Deploy Rails Apps

introduce yourself

Page 21: Using Git to Manage and Deploy Rails Apps

introduce yourselfand your sweet projects...

Page 22: Using Git to Manage and Deploy Rails Apps

why is scott here?

Page 23: Using Git to Manage and Deploy Rails Apps

What is Git?

Page 24: Using Git to Manage and Deploy Rails Apps

2m Who is Scott?

What is Git?

How Does Git Work?

How Do I Use Git?

2m This Slide

3m

20m

12m

How Do I Deploy with Git?4m

Where Can I Learn More?2m

75%

35 min

15%

6 min

10%

4 min

75%

35 min

3m What is Git?

Page 25: Using Git to Manage and Deploy Rails Apps

git is

Page 26: Using Git to Manage and Deploy Rails Apps

directory contentmanagement system

git is

Page 27: Using Git to Manage and Deploy Rails Apps

tree history storage system

git is

Page 28: Using Git to Manage and Deploy Rails Apps

stupid content tracker

git is

Page 29: Using Git to Manage and Deploy Rails Apps

a toolkit

git is

Page 30: Using Git to Manage and Deploy Rails Apps
Page 31: Using Git to Manage and Deploy Rails Apps
Page 32: Using Git to Manage and Deploy Rails Apps

the “plumbing”

Page 33: Using Git to Manage and Deploy Rails Apps
Page 34: Using Git to Manage and Deploy Rails Apps
Page 35: Using Git to Manage and Deploy Rails Apps

the “porcelain”

Page 36: Using Git to Manage and Deploy Rails Apps
Page 37: Using Git to Manage and Deploy Rails Apps

not subversion!

git is

Page 38: Using Git to Manage and Deploy Rails Apps

forget subversion!

Page 39: Using Git to Manage and Deploy Rails Apps

not an evolution

Page 40: Using Git to Manage and Deploy Rails Apps

svnrcs cvs git

not an evolution

Page 41: Using Git to Manage and Deploy Rails Apps

svnrcs cvs git

not an evolution

Page 42: Using Git to Manage and Deploy Rails Apps

svnrcs cvs git

not an evolution

Page 43: Using Git to Manage and Deploy Rails Apps

source control taxonomy

Page 44: Using Git to Manage and Deploy Rails Apps

source control taxonomy

deltastorage

file A !1

file B

file C

C1 C2 C3 C4 C5

!2

!1 !2

!1 !2 !3

A

B

C

C1 C2 C3 C4 C5

A1

B

C1

A1

B

C2

A2

B1

C2

A2

B2

C3

DAGstorage

Page 45: Using Git to Manage and Deploy Rails Apps

source control taxonomy

deltastorage

file A !1

file B

file C

C1 C2 C3 C4 C5

!2

!1 !2

!1 !2 !3

A

B

C

C1 C2 C3 C4 C5

A1

B

C1

A1

B

C2

A2

B1

C2

A2

B2

C3

DAGstorage

Page 46: Using Git to Manage and Deploy Rails Apps

source control taxonomy

deltastorage

file A !1

file B

file C

C1 C2 C3 C4 C5

!2

!1 !2

!1 !2 !3

A

B

C

C1 C2 C3 C4 C5

A1

B

C1

A1

B

C2

A2

B1

C2

A2

B2

C3

DAGstorage

Page 47: Using Git to Manage and Deploy Rails Apps

source control taxonomy

deltastorage

file A !1

file B

file C

C1 C2 C3 C4 C5

!2

!1 !2

!1 !2 !3

A

B

C

C1 C2 C3 C4 C5

A1

B

C1

A1

B

C2

A2

B1

C2

A2

B2

C3

DAGstorage

Page 48: Using Git to Manage and Deploy Rails Apps

source control taxonomy

deltastorage

file A !1

file B

file C

C1 C2 C3 C4 C5

!2

!1 !2

!1 !2 !3

A

B

C

C1 C2 C3 C4 C5

A1

B

C1

A1

B

C2

A2

B1

C2

A2

B2

C3

DAGstorage

Page 49: Using Git to Manage and Deploy Rails Apps

source control taxonomy

deltastorage

file A !1

file B

file C

C1 C2 C3 C4 C5

!2

!1 !2

!1 !2 !3

A

B

C

C1 C2 C3 C4 C5

A1

B

C1

A1

B

C2

A2

B1

C2

A2

B2

C3

DAGstorage

Page 50: Using Git to Manage and Deploy Rails Apps

source control taxonomy

deltastorage

file A !1

file B

file C

C1 C2 C3 C4 C5

!2

!1 !2

!1 !2 !3

A

B

C

C1 C2 C3 C4 C5

A1

B

C1

A1

B

C2

A2

B1

C2

A2

B2

C3

DAGstorage

Page 51: Using Git to Manage and Deploy Rails Apps

source control taxonomy

deltastorage

file A !1

file B

file C

C1 C2 C3 C4 C5

!2

!1 !2

!1 !2 !3

A

B

C

C1 C2 C3 C4 C5

A1

B

C1

A1

B

C2

A2

B1

C2

A2

B2

C3

DAGstorage

Page 52: Using Git to Manage and Deploy Rails Apps

source control taxonomy

deltastorage

file A !1

file B

file C

C1 C2 C3 C4 C5

!2

!1 !2

!1 !2 !3

A

B

C

C1 C2 C3 C4 C5

A1

B

C1

A1

B

C2

A2

B1

C2

A2

B2

C3

DAGstorage

Page 53: Using Git to Manage and Deploy Rails Apps

source control taxonomy

deltastorage

file A !1

file B

file C

C1 C2 C3 C4 C5

!2

!1 !2

!1 !2 !3

A

B

C

C1 C2 C3 C4 C5

A1

B

C1

A1

B

C2

A2

B1

C2

A2

B2

C3

DAGstorage

Page 54: Using Git to Manage and Deploy Rails Apps

source control taxonomy

deltastorage

file A !1

file B

file C

C1 C2 C3 C4 C5

!2

!1 !2

!1 !2 !3

A

B

C

C1 C2 C3 C4 C5

A1

B

C1

A1

B

C2

A2

B1

C2

A2

B2

C3

DAGstorage

Page 55: Using Git to Manage and Deploy Rails Apps

source control taxonomy

deltastorage

file A !1

file B

file C

C1 C2 C3 C4 C5

!2

!1 !2

!1 !2 !3

A

B

C

C1 C2 C3 C4 C5

A1

B

C1

A1

B

C2

A2

B1

C2

A2

B2

C3

DAGstorage

Page 56: Using Git to Manage and Deploy Rails Apps

source control taxonomy

deltastorage

file A !1

file B

file C

C1 C2 C3 C4 C5

!2

!1 !2

!1 !2 !3

A

B

C

C1 C2 C3 C4 C5

A1

B

C1

A1

B

C2

A2

B1

C2

A2

B2

C3

DAGstorage

Page 57: Using Git to Manage and Deploy Rails Apps

source control taxonomy

deltastorage

file A !1

file B

file C

C1 C2 C3 C4 C5

!2

!1 !2

!1 !2 !3

A

B

C

C1 C2 C3 C4 C5

A1

B

C1

A1

B

C2

A2

B1

C2

A2

B2

C3

DAGstorage

Page 58: Using Git to Manage and Deploy Rails Apps

source control taxonomy

deltastorage

file A !1

file B

file C

C1 C2 C3 C4 C5

!2

!1 !2

!1 !2 !3

A

B

C

C1 C2 C3 C4 C5

A1

B

C1

A1

B

C2

A2

B1

C2

A2

B2

C3

DAGstorage

Page 59: Using Git to Manage and Deploy Rails Apps

svncvs

git

perforce

mercurial

time machinecp -r

rcs

source control taxonomy

darcs

deltastorage

DAGstorage

bazzar

bitkeeper

local

centralized

distributed

local

centralized

distributed

source control taxonomy

Page 60: Using Git to Manage and Deploy Rails Apps

svncvs

git

perforce

mercurial

time machinecp -r

rcs

source control taxonomy

darcs

deltastorage

DAGstorage

bazzar

bitkeeper

local

centralized

distributed

local

centralized

distributed

source control taxonomy

Page 61: Using Git to Manage and Deploy Rails Apps

svncvs

git

perforce

mercurial

time machinecp -r

rcs

source control taxonomy

darcs

deltastorage

DAGstorage

bazzar

bitkeeper

local

centralized

distributed

local

centralized

distributed

source control taxonomy

Page 62: Using Git to Manage and Deploy Rails Apps

svncvs

git

perforce

mercurial

time machinecp -r

rcs

source control taxonomy

darcs

deltastorage

DAGstorage

bazzar

bitkeeper

local

centralized

distributed

local

centralized

distributed

source control taxonomy

Page 63: Using Git to Manage and Deploy Rails Apps

svncvs

git

perforce

mercurial

time machinecp -r

rcs

source control taxonomy

darcs

deltastorage

DAGstorage

bazzar

bitkeeper

local

centralized

distributed

local

centralized

distributed

source control taxonomy

Page 64: Using Git to Manage and Deploy Rails Apps

svncvs

git

perforce

mercurial

time machinecp -r

rcs

source control taxonomy

darcs

deltastorage

DAGstorage

bazzar

bitkeeper

local

centralized

distributed

local

centralized

distributed

source control taxonomy

Page 65: Using Git to Manage and Deploy Rails Apps

svncvs

git

perforce

mercurial

time machinecp -r

rcs

source control taxonomy

darcs

deltastorage

DAGstorage

bazzar

bitkeeper

local

centralized

distributed

local

centralized

distributed

source control taxonomy

Page 66: Using Git to Manage and Deploy Rails Apps

svncvs

git

perforce

mercurial

time machinecp -r

rcs

source control taxonomy

darcs

deltastorage

DAGstorage

bazzar

bitkeeper

local

centralized

distributed

local

centralized

distributed

source control taxonomy

Page 67: Using Git to Manage and Deploy Rails Apps

svncvs

git

perforce

mercurial

time machinecp -r

rcs

source control taxonomy

darcs

deltastorage

DAGstorage

bazzar

bitkeeper

local

centralized

distributed

local

centralized

distributed

source control taxonomy

bazaar

Page 68: Using Git to Manage and Deploy Rails Apps

How Does Git Work?

Page 69: Using Git to Manage and Deploy Rails Apps

How Does Git Work?

?

Page 70: Using Git to Manage and Deploy Rails Apps

2m Who is Scott?

What is Git?

How Does Git Work?

How Do I Use Git?

2m This Slide

3m

20m

12m

How Do I Deploy with Git?4m

Where Can I Learn More?2m

75%

35 min

15%

6 min

10%

4 min

75%

35 min

20m How Does Git Work?

Page 71: Using Git to Manage and Deploy Rails Apps

git

Page 72: Using Git to Manage and Deploy Rails Apps

git directory

Page 73: Using Git to Manage and Deploy Rails Apps

git directory

.git

Page 74: Using Git to Manage and Deploy Rails Apps

git directory

.git

GIT_DIR

Page 75: Using Git to Manage and Deploy Rails Apps

Git Directoryconfig file

hooks

index

object database

references

Page 76: Using Git to Manage and Deploy Rails Apps

object database

Page 77: Using Git to Manage and Deploy Rails Apps

object databasecontent

Page 78: Using Git to Manage and Deploy Rails Apps

object database

new_content = type + ’ ‘ + content.size + \0 + content

content

Page 79: Using Git to Manage and Deploy Rails Apps

object database

new_content = type + ’ ‘ + content.size + \0 + content

content “header”

Page 80: Using Git to Manage and Deploy Rails Apps

object database

new_content = type + ’ ‘ + content.size + \0 + content

sha = Digest::SHA1.hexdigest(new_content)

content

Page 81: Using Git to Manage and Deploy Rails Apps

object database

new_content = type + ’ ‘ + content.size + \0 + content

sha = Digest::SHA1.hexdigest(new_content)

content

“824aed035c0aa75d64c...”

Page 82: Using Git to Manage and Deploy Rails Apps

object database

new_content = type + ’ ‘ + content.size + \0 + content

compressed = zlib::deflate(new_content)

sha = Digest::SHA1.hexdigest(new_content)

content

“824aed035c0aa75d64c...”

Page 83: Using Git to Manage and Deploy Rails Apps

object database

new_content = type + ’ ‘ + content.size + \0 + content

compressed = zlib::deflate(new_content)

sha = Digest::SHA1.hexdigest(new_content)

content

“824aed035c0aa75d64c...”

path = “.git/objects/82/4aed035c0aa75d64c...”

Page 84: Using Git to Manage and Deploy Rails Apps

object database

new_content = type + ’ ‘ + content.size + \0 + content

compressed = zlib::deflate(new_content)

sha = Digest::SHA1.hexdigest(new_content)

content

“824aed035c0aa75d64c...”

path = “.git/objects/82/4aed035c0aa75d64c...”

File.open(path, ‘w’) {|f| f.write(compressed)}

Page 85: Using Git to Manage and Deploy Rails Apps

object database

new_content = type + ’ ‘ + content.size + \0 + content

compressed = zlib::deflate(new_content)

sha = Digest::SHA1.hexdigest(new_content)

content

“824aed035c0aa75d64c...”

path = “.git/objects/82/4aed035c0aa75d64c...”

File.open(path, ‘w’) {|f| f.write(compressed)}

“loose” format

Page 86: Using Git to Manage and Deploy Rails Apps

object databasegit gc

Page 87: Using Git to Manage and Deploy Rails Apps

object databasegit gc

same file with minor differences

Page 88: Using Git to Manage and Deploy Rails Apps

object database

.git/objects/f1/032eed02413a1145c...

git gc

.git/objects/45/b983be36b73c0788d...

.git/objects/04/fb8aee105e6e445e8...

.git/objects/63/874f37013c1740acd...

.git/objects/1d/c9cbcb76cbb80fce1...

.git/objects/82/4aed035c0aa75d64c...

same file with minor differences

Page 89: Using Git to Manage and Deploy Rails Apps

object database

.git/objects/f1/032eed02413a1145c...

git gc

.git/objects/45/b983be36b73c0788d...

.git/objects/04/fb8aee105e6e445e8...

.git/objects/63/874f37013c1740acd...

.git/objects/1d/c9cbcb76cbb80fce1...

.git/objects/82/4aed035c0aa75d64c...

.git/objects/pack/pack-999727..9f600.pack

.git/objects/pack/pack-999727..9f600.idx

same file with minor differences

Page 90: Using Git to Manage and Deploy Rails Apps

object database

.git/objects/f1/032eed02413a1145c...

git gc

.git/objects/45/b983be36b73c0788d...

.git/objects/04/fb8aee105e6e445e8...

.git/objects/63/874f37013c1740acd...

.git/objects/1d/c9cbcb76cbb80fce1...

.git/objects/82/4aed035c0aa75d64c...

.git/objects/pack/pack-999727..9f600.pack

.git/objects/pack/pack-999727..9f600.idx

same file with minor differences

Page 91: Using Git to Manage and Deploy Rails Apps

object database

.git/objects/f1/032eed02413a1145c...

git gc

.git/objects/45/b983be36b73c0788d...

.git/objects/04/fb8aee105e6e445e8...

.git/objects/63/874f37013c1740acd...

.git/objects/1d/c9cbcb76cbb80fce1...

.git/objects/82/4aed035c0aa75d64c...

.git/objects/pack/pack-999727..9f600.pack

.git/objects/pack/pack-999727..9f600.idx

same file with minor differences

“packed” format

Page 92: Using Git to Manage and Deploy Rails Apps

object database

all git objects are stored this way

Page 93: Using Git to Manage and Deploy Rails Apps

object database

new_content = type + ’ ‘ + content.size + \0 + content

4 types of git objects

Page 94: Using Git to Manage and Deploy Rails Apps

object database

blob

Page 95: Using Git to Manage and Deploy Rails Apps

object database

blob tree

Page 96: Using Git to Manage and Deploy Rails Apps

object database

commit

blob tree

Page 97: Using Git to Manage and Deploy Rails Apps

object database

commit tag

blob tree

Page 98: Using Git to Manage and Deploy Rails Apps

object database

blob

Page 99: Using Git to Manage and Deploy Rails Apps

Rakele

README

simplegit.rb

./

lib/

blob : a874b7

blob : a906cb

blob : a0a60a

Working Directory Git Directory

object databaseblob

Page 100: Using Git to Manage and Deploy Rails Apps

object database{SimpleGit Ruby Library======================

This library calls git commands and returns the output.

Author : Scott Chacon

blob [content size]\0

Zlib::Inflate

blob : a906cb

zlib::deflate

Page 101: Using Git to Manage and Deploy Rails Apps

object database{SimpleGit Ruby Library======================

This library calls git commands and returns the output.

Author : Scott Chacon

blob [content size]\0

Zlib::Inflate

blob : a906cb

content

zlib::deflate

Page 102: Using Git to Manage and Deploy Rails Apps

object database{SimpleGit Ruby Library======================

This library calls git commands and returns the output.

Author : Scott Chacon

blob [content size]\0

Zlib::Inflate

blob : a906cb

content

header

zlib::deflate

Page 103: Using Git to Manage and Deploy Rails Apps

object database{SimpleGit Ruby Library======================

This library calls git commands and returns the output.

Author : Scott Chacon

blob [content size]\0

Zlib::Inflate

blob : a906cb

content

header

compress zlib::deflate

Page 104: Using Git to Manage and Deploy Rails Apps

object database{SimpleGit Ruby Library======================

This library calls git commands and returns the output.

Author : Scott Chacon

blob [content size]\0

Zlib::Inflate

blob : a906cb

content

header

compress

object

zlib::deflate

Page 105: Using Git to Manage and Deploy Rails Apps

object database

commit tag

blob tree

Page 106: Using Git to Manage and Deploy Rails Apps

object database

tree

Page 107: Using Git to Manage and Deploy Rails Apps

object databasetree

Rakele

README

simplegit.rb

./

lib/

blob : a874b7

blob : a906cb

blob : a0a60a

Working Directory Git Directory

Page 108: Using Git to Manage and Deploy Rails Apps

object databasetree

Rakele

README

simplegit.rb

./

lib/

tree : 1a738d

tree : fe8971

Working Directory Git Directory

blob : a874b7

blob : a906cb

blob : a0a60a

Page 109: Using Git to Manage and Deploy Rails Apps

object database{100644 blob a906cb README100644 blob a874b7 Rakefile040000 tree fe8971 lib

tree [content size]\0

tree : 1a738d

Zlib::Inflatezlib::deflate

Page 110: Using Git to Manage and Deploy Rails Apps

object database{100644 blob a906cb README100644 blob a874b7 Rakefile040000 tree fe8971 lib

tree [content size]\0

tree : 1a738d

Zlib::Inflate

filename“inode” info

zlib::deflate

Page 111: Using Git to Manage and Deploy Rails Apps

object database{100644 blob a906cb README100644 blob a874b7 Rakefile040000 tree fe8971 lib

tree [content size]\0

tree : 1a738d

Zlib::Inflate

“block pointer”typemode

zlib::deflate

Page 112: Using Git to Manage and Deploy Rails Apps

object database

commit tag

blob tree

Page 113: Using Git to Manage and Deploy Rails Apps

object database

commit

Page 114: Using Git to Manage and Deploy Rails Apps

commit

tree

blob

tree

tree blob

blob

branch

HEAD

object databasecommit

Page 115: Using Git to Manage and Deploy Rails Apps

object database{Zlib::Inflate

tree e1b3ecparent a11befauthor Scott Chacon <[email protected]> 1205624433committer Scott Chacon <[email protected]> 1205624433

my second commit, which is better than the first

commit [content size]\0

commit : e1b3ec

zlib::deflate

Page 116: Using Git to Manage and Deploy Rails Apps

object database{Zlib::Inflate

tree e1b3ecparent a11befauthor Scott Chacon <[email protected]> 1205624433committer Scott Chacon <[email protected]> 1205624433

my second commit, which is better than the first

commit [content size]\0

commit : e1b3ec

zlib::deflate

Page 117: Using Git to Manage and Deploy Rails Apps

object database{Zlib::Inflate

tree e1b3ecparent a11befauthor Scott Chacon <[email protected]> 1205624433committer Scott Chacon <[email protected]> 1205624433

my second commit, which is better than the first

commit [content size]\0

commit : e1b3ec

zlib::deflate

Page 118: Using Git to Manage and Deploy Rails Apps

object database{Zlib::Inflate

tree e1b3ecparent a11befauthor Scott Chacon <[email protected]> 1205624433committer Scott Chacon <[email protected]> 1205624433

my second commit, which is better than the first

commit [content size]\0

commit : e1b3ec

zlib::deflate

Page 119: Using Git to Manage and Deploy Rails Apps

object database{Zlib::Inflate

tree e1b3ecparent a11befauthor Scott Chacon <[email protected]> 1205624433committer Scott Chacon <[email protected]> 1205624433

my second commit, which is better than the first

commit [content size]\0

commit : e1b3ec

zlib::deflate

Page 120: Using Git to Manage and Deploy Rails Apps

blob

branch

HEAD

commit

remote

tree

tag

object database

Page 121: Using Git to Manage and Deploy Rails Apps

object database

commit tag

blob tree

Page 122: Using Git to Manage and Deploy Rails Apps

object database

tag

Page 123: Using Git to Manage and Deploy Rails Apps

blob

branch

HEAD

commit

remote

tree

tag

object databasetag

Page 124: Using Git to Manage and Deploy Rails Apps

object database{Zlib::Inflate

object 0576fatype committag v0.1tagger Scott Chacon <[email protected]> 1205624655

this is my v0.1 tag

tag [content size]\0

tag : 0c819c

zlib::deflate

Page 125: Using Git to Manage and Deploy Rails Apps

object database{Zlib::Inflate

object 0576fatype committag v0.1tagger Scott Chacon <[email protected]> 1205624655

this is my v0.1 tag

tag [content size]\0

tag : 0c819c

zlib::deflate

Page 126: Using Git to Manage and Deploy Rails Apps

object database{Zlib::Inflate

object 0576fatype committag v0.1tagger Scott Chacon <[email protected]> 1205624655

this is my v0.1 tag

tag [content size]\0

tag : 0c819c

zlib::deflate

Page 127: Using Git to Manage and Deploy Rails Apps

object database{Zlib::Inflate

object 0576fatype committag v0.1tagger Scott Chacon <[email protected]> 1205624655

this is my v0.1 tag

tag [content size]\0

tag : 0c819c

zlib::deflate

Page 128: Using Git to Manage and Deploy Rails Apps

object database{Zlib::Inflate

object 0576fatype committag v0.1tagger Scott Chacon <[email protected]> 1205624655

this is my v0.1 tag

tag [content size]\0

tag : 0c819c

zlib::deflate

Page 129: Using Git to Manage and Deploy Rails Apps

object database

commit tag

blob tree

Page 130: Using Git to Manage and Deploy Rails Apps

object database

commit tag

blob tree

immutable

Page 131: Using Git to Manage and Deploy Rails Apps

object database

commit tag

blob tree

immutable

can’t be muted

Page 132: Using Git to Manage and Deploy Rails Apps

Git Directoryconfig file

hooks

index

object database

references

Page 133: Using Git to Manage and Deploy Rails Apps

references

Page 134: Using Git to Manage and Deploy Rails Apps

blob

branch

HEAD

commit

remote

tree

tag

referenceslightweight, movablepointers to a commit

Page 135: Using Git to Manage and Deploy Rails Apps

blob

branch

HEAD

commit

remote

tree

tag

referenceslightweight, movablepointers to a commit

stored in .git/refs/*as simple files

Page 136: Using Git to Manage and Deploy Rails Apps

blob

branch

HEAD

commit

remote

tree

tag

references

Page 137: Using Git to Manage and Deploy Rails Apps

the object model

Page 138: Using Git to Manage and Deploy Rails Apps

commit

tree

blob

tree

tree blob

blob

branch

HEAD

Page 139: Using Git to Manage and Deploy Rails Apps

commit

tree

blob

tree

tree blob

blob

branch

HEAD

Page 140: Using Git to Manage and Deploy Rails Apps

commit

tree

blob

tree

tree blob

blob

branch

HEAD

Page 141: Using Git to Manage and Deploy Rails Apps

commit

tree

blob

tree

tree

commit

tree

blob

tree

tree blob

blob

branch

HEAD

tag

Page 142: Using Git to Manage and Deploy Rails Apps

commit

tree

blob

tree

tree

commit

tree

blob

tree

tree blob

blob

branch

HEAD

tag

Page 143: Using Git to Manage and Deploy Rails Apps

commit

tree

blob

tree

tree

commit

tree

blob

tree

tree blob

blob

branch

HEAD

tag

Page 144: Using Git to Manage and Deploy Rails Apps

commit

tree

blob

tree

tree

commit

tree

blob

tree

tree blob

blob

branch

HEAD

tag

Page 145: Using Git to Manage and Deploy Rails Apps

commit

tree

blob

tree

tree

commit

tree

blob

tree

tree blob

blob

branch

HEAD

tag

Page 146: Using Git to Manage and Deploy Rails Apps

commit

tree

blob

tree

tree

commit

tree

blob

tree

tree blob

blob

branch

HEAD

tag

Page 147: Using Git to Manage and Deploy Rails Apps

commit

tag

tree

blob

tree

tree

commit

tree

blob

tree

tree blob

commit

tree

blob

blob

branch

HEAD

Page 148: Using Git to Manage and Deploy Rails Apps

commit

tag

tree

blob

tree

tree

commit

tree

blob

tree

tree blob

commit

tree

blob

blob

branch

HEAD

Page 149: Using Git to Manage and Deploy Rails Apps

commit

tag

tree

blob

tree

tree

commit

tree

blob

tree

tree blob

commit

tree

blob

blob

branch

HEAD

Page 150: Using Git to Manage and Deploy Rails Apps

commit

tag

tree

blob

tree

tree

commit

tree

blob

tree

tree blob

commit

tree

blob

blob

branch

HEAD

Page 151: Using Git to Manage and Deploy Rails Apps

commit

tag

tree

blob

tree

tree

commit

tree

blob

tree

tree blob

commit

tree

blob

blob

branch

HEAD

Page 152: Using Git to Manage and Deploy Rails Apps

commit

tag

tree

blob

tree

tree

commit

tree

blob

tree

tree blob

commit

tree

blob

blob

branch

HEAD

Page 153: Using Git to Manage and Deploy Rails Apps

commit : a11bef

tag : 0c819c

tree : 1a738d

tree : fe8971

blob : a874b7

blob : a906cb

blob : a0a60a

README

Rakefile

lib

simplegit.rb

$ git checkout v0.1

.git/refs/tags/v0.1 "0c819c"

1

2

3

Page 154: Using Git to Manage and Deploy Rails Apps

commit : a11bef

tag : 0c819c

tree : 1a738d

tree : fe8971

blob : a874b7

blob : a906cb

blob : a0a60a

README

Rakefile

lib

simplegit.rb

$ git checkout v0.1

.git/refs/tags/v0.1 "0c819c"

1

2

3

Page 155: Using Git to Manage and Deploy Rails Apps

commit : a11bef

tag : 0c819c

tree : 1a738d

tree : fe8971

blob : a874b7

blob : a906cb

blob : a0a60a

README

Rakefile

lib

simplegit.rb

$ git checkout v0.1

.git/refs/tags/v0.1 "0c819c"

1

2

3

Page 156: Using Git to Manage and Deploy Rails Apps

commit : a11bef

tag : 0c819c

tree : 1a738d

tree : fe8971

blob : a874b7

blob : a906cb

blob : a0a60a

README

Rakefile

lib

simplegit.rb

$ git checkout v0.1

.git/refs/tags/v0.1 "0c819c"

1

2

3

Page 157: Using Git to Manage and Deploy Rails Apps

commit : a11bef

tag : 0c819c

tree : 1a738d

tree : fe8971

blob : a874b7

blob : a906cb

blob : a0a60a

README

Rakefile

lib

simplegit.rb

$ git checkout v0.1

.git/refs/tags/v0.1 "0c819c"

1

2

3

Page 158: Using Git to Manage and Deploy Rails Apps

the commit history

Page 159: Using Git to Manage and Deploy Rails Apps

blob

commit

treeC1}

branch

branch

Page 160: Using Git to Manage and Deploy Rails Apps

branching and merging

Page 161: Using Git to Manage and Deploy Rails Apps

C1

master

C0

C2 C3

experiment

HEAD

Page 162: Using Git to Manage and Deploy Rails Apps

C1

master

C0

C2 C3

experimentC1

master

C0

C2 C3

C4

experiment

C5

T1

git checkout -b experiment

HEAD

Page 163: Using Git to Manage and Deploy Rails Apps

C1

master

C0

C2 C3

experiment

C1

master

C0

C2 C3

C4

experiment

C5

T1

git commit

HEAD

Page 164: Using Git to Manage and Deploy Rails Apps

C1

master

C0

C2 C3

experiment

C1

master

C0

C2 C3

C4

experiment

C5

T1

git commitgit commit

HEAD

Page 165: Using Git to Manage and Deploy Rails Apps

C1

master

C0

C2 C3

experiment

C1

master

C0

C2 C3

C4

experiment

C5

T1

HEAD

git checkout master

Page 166: Using Git to Manage and Deploy Rails Apps

C1

master

C0

C2 C3

C4

experiment

C5

T1

C1

master

C0

C2 C3

C4

experiment

C5

T1git commit

HEAD

Page 167: Using Git to Manage and Deploy Rails Apps

C1

master

C0

C2 C3

C4

experiment

C5

T1

C1

master

C0

C2 C3

C4

experiment

C5

T1git tag -a ‘v1.1’

HEAD

Page 168: Using Git to Manage and Deploy Rails Apps

C1

master

C0

C2 C3

C4

experiment

C5

T1

git checkout experimentgit commit

HEAD

Page 169: Using Git to Manage and Deploy Rails Apps

C1C0

C2 C3

C4

experiment

C5

C6

masterT1

git checkout mastergit merge experiment

HEAD

Page 170: Using Git to Manage and Deploy Rails Apps

remotes

Page 171: Using Git to Manage and Deploy Rails Apps

C1

origin/master

C0 C2

masterC1

origin/master

C0 C2

master

Page 172: Using Git to Manage and Deploy Rails Apps

C1

origin/master

C0 C2

masterC1

origin/master

C0 C2

master

Page 173: Using Git to Manage and Deploy Rails Apps

C1

origin/master

C0 C2

master

C1

origin/master

C0 C2

master

Page 174: Using Git to Manage and Deploy Rails Apps

git fetch originCL1

origin/master

C0 CL2

master

CR3CR1 CR4

origin/idea

CR2

Page 175: Using Git to Manage and Deploy Rails Apps

CL1

origin/master

C0 CL2

master

CR3CR1 CR4

origin/idea

CR2

git fetch origin

Page 176: Using Git to Manage and Deploy Rails Apps

CL1

origin/master

C0 CL2

master

CR3CR1 CR4

origin/idea

CR2

git checkout -b tryidea

CL1

origin/master

C0 CL2

master

CR3CR1 CR4

origin/idea

CR2

tryidea

CL3

Page 177: Using Git to Manage and Deploy Rails Apps

CL1

origin/master

C0 CL2

master

CR3CR1 CR4

origin/idea

CR2

tryidea

CL3

git merge origin/master origin/idea

Page 178: Using Git to Manage and Deploy Rails Apps

CL1

origin/master

C0 CL2

master

CR3CR1 CR4

origin/idea

CR2

tryidea

CL3

Page 179: Using Git to Manage and Deploy Rails Apps

CL1

origin/master

C0 CL2

master

CR3CR1 CR4

origin/idea

CR2

Page 180: Using Git to Manage and Deploy Rails Apps

remote workflow

Page 181: Using Git to Manage and Deploy Rails Apps

public repo

local repo

local repo

public repo

internet

A B C

Page 182: Using Git to Manage and Deploy Rails Apps

public repo

local repo

local repo

public repo

git push(ssh)

internet

A B C

A B C

Page 183: Using Git to Manage and Deploy Rails Apps

public repo

local repo

local repo

public repo

git push(ssh)

git fetch(git)

internet

A B C

A B C

A B C

Page 184: Using Git to Manage and Deploy Rails Apps

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

Page 185: Using Git to Manage and Deploy Rails Apps

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

Page 186: Using Git to Manage and Deploy Rails Apps

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

Page 187: Using Git to Manage and Deploy Rails Apps

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

Page 188: Using Git to Manage and Deploy Rails Apps

multiple remotes

Page 189: Using Git to Manage and Deploy Rails Apps

developernick

developerjessica

my repo5ec

e4a4a7ce0 master

Page 190: Using Git to Manage and Deploy Rails Apps

developernick

developerjessica

my repo5ec

e4a4a7ce0 master

commit

Page 191: Using Git to Manage and Deploy Rails Apps

developernick

developerjessica

my repo5ec

e4a4a7ce0 master

tree

Page 192: Using Git to Manage and Deploy Rails Apps

developernick

developerjessica

my repo5ec

e4a4a7ce0 master

blobs

Page 193: Using Git to Manage and Deploy Rails Apps

schacon/project

developernick

developerjessica

"public"

my repo5ec

e4a4a7ce0 master

git push public

public/master

5ece4a

4a7ce0

Page 194: Using Git to Manage and Deploy Rails Apps

schacon/project

developerjessica

"public"

my repo5ec

e4a4a7ce0 master

git clone (url)

public/master

5ece4a

4a7ce0

5ece4a

4a7ce0developer

nick

Page 195: Using Git to Manage and Deploy Rails Apps

schacon/project

developerjessica

"public"

my repo5ec

e4a4a7ce0 master

git commit

public/master

5ece4a

4a7ce0

5ece4a

4a7ce0developer

nickc12ec524f

Page 196: Using Git to Manage and Deploy Rails Apps

schacon/project

"public"

my repo5ec

e4a4a7ce0 master

public/master

5ece4a

4a7ce0

5ece4a

4a7ce0developer

nickc12ec524f git clone (url)

5ece4a

4a7ce0developer

jessica

Page 197: Using Git to Manage and Deploy Rails Apps

schacon/project

"public"

my repo5ec

e4a4a7ce0 master

public/master

5ece4a

4a7ce0

5ece4a

4a7ce0developer

nickc12ec524f

5ece4a

4a7ce0developer

jessica2fbdf74ea

a09git commit

Page 198: Using Git to Manage and Deploy Rails Apps

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

Page 199: Using Git to Manage and Deploy Rails Apps

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

Page 200: Using Git to Manage and Deploy Rails Apps

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

Page 201: Using Git to Manage and Deploy Rails Apps

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

Page 202: Using Git to Manage and Deploy Rails Apps

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”

Page 203: Using Git to Manage and Deploy Rails Apps

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

Page 204: Using Git to Manage and Deploy Rails Apps

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

Page 205: Using Git to Manage and Deploy Rails Apps

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

Page 206: Using Git to Manage and Deploy Rails Apps

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

Page 207: Using Git to Manage and Deploy Rails Apps

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

Page 208: Using Git to Manage and Deploy Rails Apps

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

Page 209: Using Git to Manage and Deploy Rails Apps

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

Page 210: Using Git to Manage and Deploy Rails Apps

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

Page 211: Using Git to Manage and Deploy Rails Apps

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

Page 212: Using Git to Manage and Deploy Rails Apps

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

Page 213: Using Git to Manage and Deploy Rails Apps

rebasing

Page 214: Using Git to Manage and Deploy Rails Apps

C1

C2

local jessica

master

Page 215: Using Git to Manage and Deploy Rails Apps

C1

masterC2

C1

C2

local jessica

master

git clone

Page 216: Using Git to Manage and Deploy Rails Apps

C1

master

C2

C3

C4

C1

C2

C5

C6

local jessica

master git commit

git commit

Page 217: Using Git to Manage and Deploy Rails Apps

C1

master

C2

C3

C4

C1

C2

local jessica

pack

master

git fetch jessC6

C5

Page 218: Using Git to Manage and Deploy Rails Apps

C1

jess/master

C2

C3

C4

C5

C6

local

master

Page 219: Using Git to Manage and Deploy Rails Apps

C1

jess/master

C2

C3

C4

C5

C6master

git merge

Page 220: Using Git to Manage and Deploy Rails Apps

C1

jess/master

C2

C3

C4

C5

C6

git merge

C7master

Page 221: Using Git to Manage and Deploy Rails Apps

C1

jess/master

C2

C3

C4

C5

C6

git merge

C7master

C1

jess/master

C2

C3

C4

C5

C6master

git rebase

Page 222: Using Git to Manage and Deploy Rails Apps

C3'

C4'

C3

C4

C1

jess/master

C2

C3

C4

C5

C6

git merge

C7master

C1

jess/master

C2

C5

C6

master

git rebase

Page 223: Using Git to Manage and Deploy Rails Apps

C3'

C4'

C3

C4

C1

jess/master

C2

C3

C4

C5

C6

git merge

C7master

C1

jess/master

C2

C5

C6

master

git rebase

Page 224: Using Git to Manage and Deploy Rails Apps

C3'

C4'

C3

C4

C1

jess/master

C2

C3

C4

C5

C6

git merge

C7master

C1

jess/master

C2

C5

C6

master

git rebase

1

2

Page 225: Using Git to Manage and Deploy Rails Apps

C3'

C4'

C3

C4

C1

jess/master

C2

C3

C4

C5

C6

git merge

C7master

C1

jess/master

C2

C5

C6

master

git rebase

1

2

Page 226: Using Git to Manage and Deploy Rails Apps

C3'

C4'

C3

C4

C1

jess/master

C2

C3

C4

C5

C6

git merge

C7master

C1

jess/master

C2

C5

C6

master

git rebase

Page 227: Using Git to Manage and Deploy Rails Apps

C3'

C4'

C1

jess/master

C2

C3

C4

C5

C6

git merge

C7master

C1

jess/master

C2

C5

C6

master

git rebase

Page 228: Using Git to Manage and Deploy Rails Apps

the treeish

Page 229: Using Git to Manage and Deploy Rails Apps

the treeish

alternate ways to refer to objects or ranges of objects

Page 230: Using Git to Manage and Deploy Rails Apps

Treeish

• full sha-1

• partial sha-1

• branch or tag name

• date spec

• ordinal spec

• carrot parent

• tilde spec

• tree pointer

• blob spec

• ranges

Page 231: Using Git to Manage and Deploy Rails Apps

Full SHA1

6e453f523fa1da50ecb04431101112b3611c6a4d

Page 232: Using Git to Manage and Deploy Rails Apps

Partial SHA16e453f523fa1da50ecb04431101112b3611c6a4d

6e453f523fa1da50

6e453

Page 233: Using Git to Manage and Deploy Rails Apps

Branch, Remote or Tag Name

v1.0

master

origin/testing

Page 234: Using Git to Manage and Deploy Rails Apps

Date Spec

master@{yesterday}

master@{1 month ago}

Page 235: Using Git to Manage and Deploy Rails Apps

Ordinal Spec

master@{5}

5th prior value of ‘master’

Page 236: Using Git to Manage and Deploy Rails Apps

Carrot Parent

master^2

2nd parent of ‘master’

Page 237: Using Git to Manage and Deploy Rails Apps

Tilde Spec

master~2

2nd generation grandparent of ‘master’

Page 238: Using Git to Manage and Deploy Rails Apps

Tree Pointer

master^{tree}

tree that ‘master’ points to

Page 239: Using Git to Manage and Deploy Rails Apps

Blob Spec

master:/path/to/file

blob of that file in ‘master’ commit

Page 240: Using Git to Manage and Deploy Rails Apps

Ranges

ce0e4..e4272

everything between two commits

Page 241: Using Git to Manage and Deploy Rails Apps

Ranges

ce0e4..

everything since a commit

Page 242: Using Git to Manage and Deploy Rails Apps

examples

Page 243: Using Git to Manage and Deploy Rails Apps

ce0e4

master

5ec47 2f45e 4eadf 2fbb3 18cae

b3be1 a09c6 df2fa c36ae

jess/master

Page 244: Using Git to Manage and Deploy Rails Apps

ce0e4

master

5ec47 2f45e 4eadf 2fbb3 18cae

b3be1 a09c6 df2fa c36ae

jess/master

master^

Page 245: Using Git to Manage and Deploy Rails Apps

ce0e4

master

5ec47 2f45e 4eadf 2fbb3 18cae

b3be1 a09c6 df2fa c36ae

jess/master

master^2

Page 246: Using Git to Manage and Deploy Rails Apps

ce0e4

master

5ec47 2f45e 4eadf 2fbb3 18cae

b3be1 a09c6 df2fa c36ae

jess/master

master~2

Page 247: Using Git to Manage and Deploy Rails Apps

ce0e4

master

5ec47 2f45e 4eadf 2fbb3 18cae

b3be1 a09c6 df2fa c36ae

jess/master

master^^^2master~2^2

Page 248: Using Git to Manage and Deploy Rails Apps

ce0e4

master

5ec47 2f45e 4eadf 2fbb3 18cae

b3be1 a09c6 df2fa c36ae

jess/master

master^^^2master~2^2

Page 249: Using Git to Manage and Deploy Rails Apps

ce0e4

master

5ec47 2f45e 4eadf 2fbb3 18cae

b3be1 a09c6 df2fa c36ae

jess/master

master^^^2master~2^2

Page 250: Using Git to Manage and Deploy Rails Apps

ce0e4

master

5ec47 2f45e 4eadf 2fbb3 18cae

b3be1 a09c6 df2fa c36ae

jess/master

master~3..master^

Page 251: Using Git to Manage and Deploy Rails Apps

local stuff

Page 252: Using Git to Manage and Deploy Rails Apps

the index

Page 253: Using Git to Manage and Deploy Rails Apps

Git Directoryconfig file

hooks

index

object database

references

Page 254: Using Git to Manage and Deploy Rails Apps

index

Page 255: Using Git to Manage and Deploy Rails Apps

index

working directory

repository

index

git add

git commit

Page 256: Using Git to Manage and Deploy Rails Apps

index

working directory

repository

index

git add

git commit

Page 257: Using Git to Manage and Deploy Rails Apps

index

working directory

repository

index

git add

git commit

Page 258: Using Git to Manage and Deploy Rails Apps

what?

Page 259: Using Git to Manage and Deploy Rails Apps

5ec

e4a

4a7

ce0

master

ec5

24f

c12

HEAD git wdir mtime fname

Object Directory Working DirectoryIndex

project/.git/index project/project/.git/objects

stage

Page 260: Using Git to Manage and Deploy Rails Apps

5ec

e4a

4a7

ce0

master

ec5

24f

c12

HEAD git wdir mtime fname

Object Directory Working DirectoryIndex

project/.git/index project/project/.git/objects

stage

git checkout

Page 261: Using Git to Manage and Deploy Rails Apps

5ec

e4a

4a7

ce0

master

ec5

24f

c12

HEAD

Object Directory Working Directory

project/project/.git/objects

e4a

24f

e4a

24f file1

file2

1:30

1:30

git wdir mtime fname

Index

project/.git/index

e4a

24f

stage

/file1

/file2

1:30

1:30

git checkout

5ec

e4a

4a7

ce0

master

ec5

24f

c12

HEAD git wdir mtime fname

Object Directory Working DirectoryIndex

project/.git/index project/project/.git/objects

stage

Page 262: Using Git to Manage and Deploy Rails Apps

5ec

e4a

4a7

ce0

master

ec5

24f

c12

HEAD

Object Directory Working Directory

project/project/.git/objects

e4a

24f

e4a

24f file1

file2

1:30

1:30

git wdir mtime fname

Index

project/.git/index

e4a

24f

stage

/file1

/file2

1:30

1:30

git checkout

5ec

e4a

4a7

ce0

master

ec5

24f

c12

HEAD git wdir mtime fname

Object Directory Working DirectoryIndex

project/.git/index project/project/.git/objects

stage

Page 263: Using Git to Manage and Deploy Rails Apps

5ec

e4a

4a7

ce0

master

ec5

24f

c12

HEAD

Object Directory Working Directory

project/project/.git/objects

e4a

24f

e4a

24f file1

file2

1:30

1:30

git wdir mtime fname

Index

project/.git/index

e4a

24f

stage

/file1

/file2

1:30

1:30

git checkout

5ec

e4a

4a7

ce0

master

ec5

24f

c12

HEAD git wdir mtime fname

Object Directory Working DirectoryIndex

project/.git/index project/project/.git/objects

stage

Page 264: Using Git to Manage and Deploy Rails Apps

5ec

e4a

4a7

ce0

master

ec5

24f

c12

HEAD

Object Directory Working Directory

project/project/.git/objects

e4a

24f

e4a

24f file1

file2

1:30

1:30

git wdir mtime fname

Index

project/.git/index

e4a

24f

stage

/file1

/file2

1:30

1:30

git checkout

5ec

e4a

4a7

ce0

master

ec5

24f

c12

HEAD git wdir mtime fname

Object Directory Working DirectoryIndex

project/.git/index project/project/.git/objects

stage

Page 265: Using Git to Manage and Deploy Rails Apps

5ec

e4a

4a7

ce0

master

ec5

24f

c12

HEAD

Object Directory Working Directory

project/project/.git/objects

e4a

24f

e4a

24f file1

file2

1:30

1:30

git wdir mtime fname

Index

project/.git/index

e4a

24f

stage

/file1

/file2

1:30

1:30

git checkout

5ec

e4a

4a7

ce0

master

ec5

24f

c12

HEAD git wdir mtime fname

Object Directory Working DirectoryIndex

project/.git/index project/project/.git/objects

stage

Page 266: Using Git to Manage and Deploy Rails Apps

5ec

e4a

4a7

ce0

master

ec5

24f

c12

HEAD

Object Directory Working Directory

project/project/.git/objects

e4a

24f

e4a

24f file1

file2

1:30

1:30

git wdir mtime fname

Index

project/.git/index

e4a

24f

stage

/file1

/file2

1:30

1:30

git checkout

Page 267: Using Git to Manage and Deploy Rails Apps

5ec

e4a

4a7

ce0

master

ec5

24f

c12

HEAD

Object Directory Working Directory

project/project/.git/objects

e4a

24f

e4a

24f file1

file2

1:30

1:30

git wdir mtime fname

Index

project/.git/index

e4a

24f

stage

/file1

/file2

1:30

1:31

vim file2

Page 268: Using Git to Manage and Deploy Rails Apps

5ec

e4a

4a7

ce0

master

ec5

24f

c12

HEAD

Object Directory Working Directory

project/project/.git/objects

1ba

24f

e4a

24f file1

file2

1:30

1:31

git wdir mtime fname

Index

project/.git/index

e4a

24f

stage

/file1

/file2

1:30

1:31

git status

Page 269: Using Git to Manage and Deploy Rails Apps

5ec

e4a

4a7

ce0

master

ec5

24f

c12

HEAD

Object Directory Working Directory

project/project/.git/objects

1ba

24f

e4a

24f file1

file2

1:30

1:31

git wdir mtime fname

Index

project/.git/index

e4a

24f

stage

/file1

/file2

1:30

1:31

git status

Page 270: Using Git to Manage and Deploy Rails Apps

5ec

e4a

4a7

ce0

master

ec5

24f

c12

HEAD

Object Directory Working Directory

project/project/.git/objects

1ba

24f

e4a

24f file1

file2

1:30

1:31

git wdir mtime fname

Index

project/.git/index

e4a

24f

stage

/file1

/file2

1:30

1:31

git status

Page 271: Using Git to Manage and Deploy Rails Apps

5ec

e4a

4a7

ce0

master

ec5

24f

c12

HEAD

Object Directory Working Directory

project/project/.git/objects

1ba

24f

e4a

24f file1

file2

1:30

1:31

git wdir mtime fname

Index

project/.git/index

e4a

24f

stage

/file1

/file2

1:30

1:31

Page 272: Using Git to Manage and Deploy Rails Apps

5ec

e4a

4a7

ce0

master

ec5

24f

c12

HEAD

Object Directory Working Directory

project/project/.git/objects

1ba

24f

e4a

24f file1

file2

1:30

1:31

git wdir mtime fname

Index

project/.git/index

1ba

24f

stage

/file1

/file2

1:30

1:311ba

git add file2

Page 273: Using Git to Manage and Deploy Rails Apps

5ec

e4a

4a7

ce0

master

ec5

24f

c12

HEAD

Object Directory Working Directory

project/project/.git/objects

1ba

24f

e4a

24f file1

file2

1:30

1:31

git wdir mtime fname

Index

project/.git/index

1ba

24f

stage

/file1

/file2

1:30

1:311ba

git add file2

Page 274: Using Git to Manage and Deploy Rails Apps

5ec

e4a

4a7

ce0

master

ec5

24f

c12

HEAD

Object Directory Working Directory

project/project/.git/objects

1ba

24f

e4a

24f file1

file2

1:30

1:31

git wdir mtime fname

Index

project/.git/index

1ba

24f

stage

/file1

/file2

1:30

1:311ba

git add file2

Page 275: Using Git to Manage and Deploy Rails Apps

5ec

e4a

4a7

ce0

master

ec5

24f

c12

HEAD

Object Directory Working Directory

project/project/.git/objects

1ba

24f

e4a

24f file1

file2

1:30

1:31

git wdir mtime fname

Index

project/.git/index

1ba

24f

stage

/file1

/file2

1:30

1:311ba

git add file2

Page 276: Using Git to Manage and Deploy Rails Apps

5ec

e4a

4a7

ce0

master

ec5

24f

c12

HEAD

Object Directory Working Directory

project/project/.git/objects

1ba

24f

e4a

24f file1

file2

1:30

1:31

git wdir mtime fname

Index

project/.git/index

1ba

24f

stage

/file1

/file2

1:30

1:311ba

git status

Page 277: Using Git to Manage and Deploy Rails Apps

5ec

e4a

4a7

ce0

master

ec5

24f

c12

HEAD

Object Directory Working Directory

project/project/.git/objects

1ba

24f

e4a

24f file1

file2

1:30

1:31

git wdir mtime fname

Index

project/.git/index

1ba

24f

stage

/file1

/file2

1:30

1:311ba

git status

Page 278: Using Git to Manage and Deploy Rails Apps

5ec

e4a

4a7

ce0

master

ec5

24f

c12

HEAD

Object Directory Working Directory

project/project/.git/objects

1ba

24f

1ba

24f file1

file2

1:30

1:31

git wdir mtime fname

Index

project/.git/index

1ba

24f

stage

/file1

/file2

1:30

1:311ba

a3e

83d

git commit

Page 279: Using Git to Manage and Deploy Rails Apps

5ec

e4a

4a7

ce0

master

ec5

24f

c12

HEAD

Object Directory Working Directory

project/project/.git/objects

1ba

24f

1ba

24f file1

file2

1:30

1:31

git wdir mtime fname

Index

project/.git/index

1ba

24f

stage

/file1

/file2

1:30

1:311ba

a3e

83d

git commit

Page 280: Using Git to Manage and Deploy Rails Apps

5ec

e4a

4a7

ce0

master

ec5

24f

c12

HEAD

Object Directory Working Directory

project/project/.git/objects

1ba

24f

1ba

24f file1

file2

1:30

1:31

git wdir mtime fname

Index

project/.git/index

1ba

24f

stage

/file1

/file2

1:30

1:311ba

a3e

83d

git commit

Page 281: Using Git to Manage and Deploy Rails Apps

5ec

e4a

4a7

ce0

master

ec5

24f

c12

HEAD

Object Directory Working Directory

project/project/.git/objects

1ba

24f

1ba

24f file1

file2

1:30

1:31

git wdir mtime fname

Index

project/.git/index

1ba

24f

stage

/file1

/file2

1:30

1:311ba

a3e

83d

git commit

Page 282: Using Git to Manage and Deploy Rails Apps

5ec

e4a

4a7

ce0

master

ec5

24f

c12

HEAD

Object Directory Working Directory

project/project/.git/objects

6d4

91b

1ba

24f file1

file2

1:32

1:32

git wdir mtime fname

Index

project/.git/index

1ba

24f

stage

/file1

/file2

1:32

1:321ba

a3e

83d

vim file1 file2 git status

Page 283: Using Git to Manage and Deploy Rails Apps

5ec

e4a

4a7

ce0

master

ec5

24f

c12

HEAD

Object Directory Working Directory

project/project/.git/objects

6d4

91b

1ba

24f file1

file2

1:32

1:32

git wdir mtime fname

Index

project/.git/index

1ba

24f

stage

/file1

/file2

1:32

1:321ba

a3e

83d

vim file1 file2 git status

Page 284: Using Git to Manage and Deploy Rails Apps

5ec

e4a

4a7

ce0

master

ec5

24f

c12

HEAD

Object Directory Working Directory

project/project/.git/objects

6d4

91b

1ba

24f file1

file2

1:32

1:32

git wdir mtime fname

Index

project/.git/index

1ba

24f

stage

/file1

/file2

1:32

1:321ba

a3e

83d

vim file1 file2 git status

Page 285: Using Git to Manage and Deploy Rails Apps

5ec

e4a

4a7

ce0

master

ec5

24f

c12

HEAD

Object Directory Working Directory

project/project/.git/objects

6d4

91b

1ba

24f file1

file2

1:32

1:32

git wdir mtime fname

Index

project/.git/index

1ba

91b

stage

/file1

/file2

1:32

1:321ba

a3e

83d

91b

git add file1

Page 286: Using Git to Manage and Deploy Rails Apps

5ec

e4a

4a7

ce0

master

ec5

24f

c12

HEAD

Object Directory Working Directory

project/project/.git/objects

6d4

91b

1ba

24f file1

file2

1:32

1:32

git wdir mtime fname

Index

project/.git/index

1ba

91b

stage

/file1

/file2

1:32

1:321ba

a3e

83d

91b

git add file1

Page 287: Using Git to Manage and Deploy Rails Apps

5ec

e4a

4a7

ce0

master

ec5

24f

c12

HEAD

Object Directory Working Directory

project/project/.git/objects

6d4

91b

1ba

24f file1

file2

1:32

1:32

git wdir mtime fname

Index

project/.git/index

1ba

91b

stage

/file1

/file2

1:32

1:321ba

a3e

83d

91b

git add file1

Page 288: Using Git to Manage and Deploy Rails Apps

5ec

e4a

4a7

ce0

master

ec5

24f

c12

HEAD

Object Directory Working Directory

project/project/.git/objects

6d4

91b

1ba

24f file1

file2

1:32

1:32

git wdir mtime fname

Index

project/.git/index

1ba

91b

stage

/file1

/file2

1:32

1:321ba

a3e

83d

91b

git status

Page 289: Using Git to Manage and Deploy Rails Apps

5ec

e4a

4a7

ce0

master

ec5

24f

c12

HEAD

Object Directory Working Directory

project/project/.git/objects

6d4

91b

1ba

24f file1

file2

1:32

1:32

git wdir mtime fname

Index

project/.git/index

1ba

91b

stage

/file1

/file2

1:32

1:321ba

a3e

83d

91b

git status

Page 290: Using Git to Manage and Deploy Rails Apps

5ec

e4a

4a7

ce0

master

ec5

24f

c12

HEAD

Object Directory Working Directory

project/project/.git/objects

6d4

91b

1ba

24f file1

file2

1:32

1:32

git wdir mtime fname

Index

project/.git/index

1ba

91b

stage

/file1

/file2

1:32

1:321ba

a3e

83d

91b

git status

Page 291: Using Git to Manage and Deploy Rails Apps

5ec

e4a

4a7

ce0

master

ec5

24f

c12

HEAD

Object Directory Working Directory

project/project/.git/objects

6d4

91b

1ba

91b file1

file2

1:32

1:32

git wdir mtime fname

Index

project/.git/index

1ba

91b

stage

/file1

/file2

1:32

1:321ba

a3e

83d

91b

1a7

6c5

git commit

Page 292: Using Git to Manage and Deploy Rails Apps

5ec

e4a

4a7

ce0

master

ec5

24f

c12

HEAD

Object Directory Working Directory

project/project/.git/objects

6d4

91b

1ba

91b file1

file2

1:32

1:32

git wdir mtime fname

Index

project/.git/index

1ba

91b

stage

/file1

/file2

1:32

1:321ba

a3e

83d

91b

1a7

6c5

git commit

Page 293: Using Git to Manage and Deploy Rails Apps

5ec

e4a

4a7

ce0

master

ec5

24f

c12

HEAD

Object Directory Working Directory

project/project/.git/objects

6d4

91b

1ba

91b file1

file2

1:32

1:32

git wdir mtime fname

Index

project/.git/index

1ba

91b

stage

/file1

/file2

1:32

1:321ba

a3e

83d

91b

1a7

6c5

Page 294: Using Git to Manage and Deploy Rails Apps

How Do I Use Git?

Page 295: Using Git to Manage and Deploy Rails Apps

2m Who is Scott?

What is Git?

How Does Git Work?

How Do I Use Git?

2m This Slide

3m

20m

12m

How Do I Deploy with Git?4m

Where Can I Learn More?2m

75%

35 min

15%

6 min

10%

4 min

75%

35 min

12m How Do I Use Git?

Page 296: Using Git to Manage and Deploy Rails Apps

152 Total Commands

Page 297: Using Git to Manage and Deploy Rails Apps

43 Porcelain Commands

Page 298: Using Git to Manage and Deploy Rails Apps

We’ll Cover Half

Page 299: Using Git to Manage and Deploy Rails Apps

getting git

Page 300: Using Git to Manage and Deploy Rails Apps

git.or.cz

Page 301: Using Git to Manage and Deploy Rails Apps

git.or.cz

wgetmake

make install

Page 302: Using Git to Manage and Deploy Rails Apps

yum install git-core

apt-get install git-core

port install git-core +svn

Page 303: Using Git to Manage and Deploy Rails Apps

setup

Page 304: Using Git to Manage and Deploy Rails Apps

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

git config --global user.email “[email protected]

Page 305: Using Git to Manage and Deploy Rails Apps
Page 306: Using Git to Manage and Deploy Rails Apps
Page 307: Using Git to Manage and Deploy Rails Apps

1 Down

Page 308: Using Git to Manage and Deploy Rails Apps

getting a repo

Page 309: Using Git to Manage and Deploy Rails Apps

git clone

Page 310: Using Git to Manage and Deploy Rails Apps

Git Protocols

ssh://

http[s]://

git://

file:///

rsync://

Page 311: Using Git to Manage and Deploy Rails Apps

Git Protocols

ssh://

http[s]://

git://

file:///

rsync://

Page 312: Using Git to Manage and Deploy Rails Apps

Git Protocols

ssh://

http[s]://

git://

file:///

rsync://

push

Page 313: Using Git to Manage and Deploy Rails Apps

Git Protocols

ssh://

http[s]://

git://

file:///

rsync://

pull

Page 314: Using Git to Manage and Deploy Rails Apps

git clone

Page 315: Using Git to Manage and Deploy Rails Apps

git clone

Page 316: Using Git to Manage and Deploy Rails Apps

git clone

Page 317: Using Git to Manage and Deploy Rails Apps

git clone

Page 318: Using Git to Manage and Deploy Rails Apps

initializing a repo

cd myproject

git init

git add .

git commit

Page 319: Using Git to Manage and Deploy Rails Apps
Page 320: Using Git to Manage and Deploy Rails Apps
Page 321: Using Git to Manage and Deploy Rails Apps
Page 322: Using Git to Manage and Deploy Rails Apps
Page 323: Using Git to Manage and Deploy Rails Apps
Page 324: Using Git to Manage and Deploy Rails Apps
Page 325: Using Git to Manage and Deploy Rails Apps

5 Down

Page 326: Using Git to Manage and Deploy Rails Apps

normal workflow

Page 327: Using Git to Manage and Deploy Rails Apps

.gitignore

Page 328: Using Git to Manage and Deploy Rails Apps
Page 329: Using Git to Manage and Deploy Rails Apps
Page 330: Using Git to Manage and Deploy Rails Apps

adding and committing

Page 331: Using Git to Manage and Deploy Rails Apps
Page 332: Using Git to Manage and Deploy Rails Apps
Page 333: Using Git to Manage and Deploy Rails Apps
Page 334: Using Git to Manage and Deploy Rails Apps
Page 335: Using Git to Manage and Deploy Rails Apps
Page 336: Using Git to Manage and Deploy Rails Apps

working directory

repository

index

git add

git commit

Page 337: Using Git to Manage and Deploy Rails Apps
Page 338: Using Git to Manage and Deploy Rails Apps
Page 339: Using Git to Manage and Deploy Rails Apps

working directory

repository

index

git add

git commit

Page 340: Using Git to Manage and Deploy Rails Apps

git log

Page 341: Using Git to Manage and Deploy Rails Apps
Page 342: Using Git to Manage and Deploy Rails Apps
Page 343: Using Git to Manage and Deploy Rails Apps
Page 344: Using Git to Manage and Deploy Rails Apps
Page 345: Using Git to Manage and Deploy Rails Apps
Page 346: Using Git to Manage and Deploy Rails Apps
Page 347: Using Git to Manage and Deploy Rails Apps
Page 348: Using Git to Manage and Deploy Rails Apps
Page 349: Using Git to Manage and Deploy Rails Apps

git log --pretty

Page 350: Using Git to Manage and Deploy Rails Apps
Page 351: Using Git to Manage and Deploy Rails Apps
Page 352: Using Git to Manage and Deploy Rails Apps
Page 353: Using Git to Manage and Deploy Rails Apps
Page 354: Using Git to Manage and Deploy Rails Apps
Page 355: Using Git to Manage and Deploy Rails Apps
Page 356: Using Git to Manage and Deploy Rails Apps

6 Down

Page 357: Using Git to Manage and Deploy Rails Apps

git diff

Page 358: Using Git to Manage and Deploy Rails Apps

git diff (treeish1) (treeish2)

Page 359: Using Git to Manage and Deploy Rails Apps

git diff master^ > change.diff

Page 360: Using Git to Manage and Deploy Rails Apps

git diff master^ > change.diff

patch -p1 < change.diff

Page 361: Using Git to Manage and Deploy Rails Apps

git diff master^ > change.diff

patch -p1 < change.diff

git apply change.diffor

Page 362: Using Git to Manage and Deploy Rails Apps

git and patches

Page 363: Using Git to Manage and Deploy Rails Apps

Single Commit

git format-patch origin/master --stdout > story.patch

git am < story.patch

Page 364: Using Git to Manage and Deploy Rails Apps

Multiple Commits

$ git format-patch -o patches origin$ git send-email --to [email protected] patches

$ git am mbox

Page 365: Using Git to Manage and Deploy Rails Apps

Multiple Commits

$ git format-patch -o patches origin$ git send-email --to [email protected] patches

$ git am mbox

1 patch file per commitin this directory

Page 366: Using Git to Manage and Deploy Rails Apps

example: patching rails

Page 367: Using Git to Manage and Deploy Rails Apps

Patching Rails

git clone git://github.com/rails/rails.git

cd rails; (vim/emacs etc)

git format-patch origin/master --stdout > story.patch

upload story.patch to rails.lighthouseapp.com

Page 368: Using Git to Manage and Deploy Rails Apps

Applying a Rails Patch

download story.patch from rails.lighthouseapp.com

git am < story.patch

Page 369: Using Git to Manage and Deploy Rails Apps

11 Down

Page 370: Using Git to Manage and Deploy Rails Apps

branch, merge, rebase

Page 371: Using Git to Manage and Deploy Rails Apps

master

develop

topic

Page 372: Using Git to Manage and Deploy Rails Apps

master

develop

topic

Page 373: Using Git to Manage and Deploy Rails Apps

master

develop

topic

Page 374: Using Git to Manage and Deploy Rails Apps

master

develop

topic

Page 375: Using Git to Manage and Deploy Rails Apps

master

develop

topic

Page 376: Using Git to Manage and Deploy Rails Apps

master

develop

topic

Page 377: Using Git to Manage and Deploy Rails Apps

master

develop

topic

Page 378: Using Git to Manage and Deploy Rails Apps

master

develop

topic

“production”

Page 379: Using Git to Manage and Deploy Rails Apps

master

develop

topic

“production”

“trunk”

Page 380: Using Git to Manage and Deploy Rails Apps

master

develop

topic

“production”

“trunk”convention!

Page 381: Using Git to Manage and Deploy Rails Apps

branching workflow

normal development

want to try an idea

have to do a hotfix

merge idea into development

push to production

Page 382: Using Git to Manage and Deploy Rails Apps

branching workflow

normal development

want to try an idea

have to do a hotfix

merge idea into development

push to production

Page 383: Using Git to Manage and Deploy Rails Apps
Page 384: Using Git to Manage and Deploy Rails Apps
Page 385: Using Git to Manage and Deploy Rails Apps
Page 386: Using Git to Manage and Deploy Rails Apps
Page 387: Using Git to Manage and Deploy Rails Apps
Page 388: Using Git to Manage and Deploy Rails Apps
Page 389: Using Git to Manage and Deploy Rails Apps
Page 390: Using Git to Manage and Deploy Rails Apps

C3

master

C0

develop

story95

C4

C1 C2

idea

Page 391: Using Git to Manage and Deploy Rails Apps

branching workflow

normal development

want to try an idea

have to do a hotfix

merge idea into development

push to production

Page 392: Using Git to Manage and Deploy Rails Apps
Page 393: Using Git to Manage and Deploy Rails Apps
Page 394: Using Git to Manage and Deploy Rails Apps
Page 395: Using Git to Manage and Deploy Rails Apps

C3

master

C0

develop

story95

C4

C1 C2

idea

Page 396: Using Git to Manage and Deploy Rails Apps

C3

master

C0

develop

story95

C4

C1 C2

idea

Page 397: Using Git to Manage and Deploy Rails Apps
Page 398: Using Git to Manage and Deploy Rails Apps
Page 399: Using Git to Manage and Deploy Rails Apps

idea

C3

master

C0

develop

story95

C4

C1 C2

C5

C6

master

Page 400: Using Git to Manage and Deploy Rails Apps

branching workflow

normal development

want to try an idea

have to do a hotfix

merge idea into development

push to production

Page 401: Using Git to Manage and Deploy Rails Apps
Page 402: Using Git to Manage and Deploy Rails Apps
Page 403: Using Git to Manage and Deploy Rails Apps
Page 404: Using Git to Manage and Deploy Rails Apps
Page 405: Using Git to Manage and Deploy Rails Apps
Page 406: Using Git to Manage and Deploy Rails Apps

idea

C3

master

C0

develop

story95

C4

C1 C2

C5

C6

master

Page 407: Using Git to Manage and Deploy Rails Apps

branching workflow

normal development

want to try an idea

have to do a hotfix

merge idea into development

push to production

Page 408: Using Git to Manage and Deploy Rails Apps
Page 409: Using Git to Manage and Deploy Rails Apps
Page 410: Using Git to Manage and Deploy Rails Apps
Page 411: Using Git to Manage and Deploy Rails Apps
Page 412: Using Git to Manage and Deploy Rails Apps

develop

C3

C0

story95

C4

C1 C2

C5

C6

master

Page 413: Using Git to Manage and Deploy Rails Apps

branching workflow

normal development

want to try an idea

have to do a hotfix

merge idea into development

push to production

Page 414: Using Git to Manage and Deploy Rails Apps
Page 415: Using Git to Manage and Deploy Rails Apps
Page 416: Using Git to Manage and Deploy Rails Apps

develop

C3

C0

story95

C4

C1 C2

C5

C6 C7

master

Page 417: Using Git to Manage and Deploy Rails Apps
Page 418: Using Git to Manage and Deploy Rails Apps
Page 419: Using Git to Manage and Deploy Rails Apps

develop

C4C0

story95

C5

C1 C2

C6'C3

master

Page 420: Using Git to Manage and Deploy Rails Apps

develop

C4C0

story95

C5

C1 C2

C6'C3

master

Page 421: Using Git to Manage and Deploy Rails Apps

develop

C4C0

story95

C5

C1 C2

C6'C3

master

Page 422: Using Git to Manage and Deploy Rails Apps

develop

C3

C0

story95

C4

C1 C2

C5

C6 C7

master

merge

rebasedevelop

C4C0

story95

C5

C1 C2

C6'C3

master

Page 423: Using Git to Manage and Deploy Rails Apps

one more time now!

Page 424: Using Git to Manage and Deploy Rails Apps

C3

master

C0

develop

story95

C4

C1 C2

idea

Page 425: Using Git to Manage and Deploy Rails Apps

C3

master

C0

develop

story95

C4

C1 C2

idea

git checkout -b idea

Page 426: Using Git to Manage and Deploy Rails Apps

idea

C3

master

C0

develop

story95

C4

C1 C2

C5

C6

master

git commit

Page 427: Using Git to Manage and Deploy Rails Apps

idea

C3

master

C0

develop

story95

C4

C1 C2

C5

C6

master

git checkout mastergit commit

Page 428: Using Git to Manage and Deploy Rails Apps

develop

C3

C0

story95

C4

C1 C2

C5

C6

master

git checkout ideagit merge developgit branch -d idea

Page 429: Using Git to Manage and Deploy Rails Apps

develop

C3

C0

story95

C4

C1 C2

C5

C6 C7

master

git checkout mastergit merge develop

Page 430: Using Git to Manage and Deploy Rails Apps

17 Down

Page 431: Using Git to Manage and Deploy Rails Apps

sharing git

Page 432: Using Git to Manage and Deploy Rails Apps
Page 433: Using Git to Manage and Deploy Rails Apps
Page 434: Using Git to Manage and Deploy Rails Apps
Page 435: Using Git to Manage and Deploy Rails Apps
Page 436: Using Git to Manage and Deploy Rails Apps
Page 437: Using Git to Manage and Deploy Rails Apps
Page 438: Using Git to Manage and Deploy Rails Apps
Page 439: Using Git to Manage and Deploy Rails Apps
Page 440: Using Git to Manage and Deploy Rails Apps
Page 441: Using Git to Manage and Deploy Rails Apps
Page 442: Using Git to Manage and Deploy Rails Apps
Page 443: Using Git to Manage and Deploy Rails Apps
Page 444: Using Git to Manage and Deploy Rails Apps
Page 445: Using Git to Manage and Deploy Rails Apps
Page 446: Using Git to Manage and Deploy Rails Apps
Page 447: Using Git to Manage and Deploy Rails Apps
Page 448: Using Git to Manage and Deploy Rails Apps
Page 449: Using Git to Manage and Deploy Rails Apps

git clone git://github.com/schacon/simplegit2.git

Page 450: Using Git to Manage and Deploy Rails Apps

distributed workflow

Page 451: Using Git to Manage and Deploy Rails Apps

distributed workflowfetch, pull and push

Page 452: Using Git to Manage and Deploy Rails Apps

fetch

Page 453: Using Git to Manage and Deploy Rails Apps
Page 454: Using Git to Manage and Deploy Rails Apps
Page 455: Using Git to Manage and Deploy Rails Apps
Page 456: Using Git to Manage and Deploy Rails Apps
Page 457: Using Git to Manage and Deploy Rails Apps
Page 458: Using Git to Manage and Deploy Rails Apps
Page 459: Using Git to Manage and Deploy Rails Apps

pull

Page 460: Using Git to Manage and Deploy Rails Apps

pull = fetch + merge

Page 461: Using Git to Manage and Deploy Rails Apps

push

Page 462: Using Git to Manage and Deploy Rails Apps
Page 463: Using Git to Manage and Deploy Rails Apps
Page 464: Using Git to Manage and Deploy Rails Apps
Page 465: Using Git to Manage and Deploy Rails Apps

git push

Page 466: Using Git to Manage and Deploy Rails Apps
Page 467: Using Git to Manage and Deploy Rails Apps

We Know Em All!

Page 468: Using Git to Manage and Deploy Rails Apps

review

Page 469: Using Git to Manage and Deploy Rails Apps

• Local Commands

• git config

• git init

• git add

• git commit

• git status

• git tag

• git log

Page 470: Using Git to Manage and Deploy Rails Apps

• Local Commands

• git config

• git init

• git add

• git commit

• git status

• git tag

• git log

• Branchy Commands

• git checkout

• git branch

• git merge

• git rebase

Page 471: Using Git to Manage and Deploy Rails Apps

• Local Commands

• git config

• git init

• git add

• git commit

• git status

• git tag

• git log

• Branchy Commands

• git checkout

• git branch

• git merge

• git rebase

• Remotey Commands

• git remote

• git fetch

• git pull

• git clone

• git push

Page 472: Using Git to Manage and Deploy Rails Apps

• Local Commands

• git config

• git init

• git add

• git commit

• git status

• git tag

• git log

• Branchy Commands

• git checkout

• git branch

• git merge

• git rebase

• Remotey Commands

• git remote

• git fetch

• git pull

• git clone

• git push

• Patchy Commands

• git diff

• git apply

• git format-patch

• git am

Page 473: Using Git to Manage and Deploy Rails Apps

• Local Commands

• git config

• git init

• git add

• git commit

• git status

• git tag

• git log

• Branchy Commands

• git checkout

• git branch

• git merge

• git rebase

• Remotey Commands

• git remote

• git fetch

• git pull

• git clone

• git push

• Patchy Commands

• git diff

• git apply

• git format-patch

• git am

Page 474: Using Git to Manage and Deploy Rails Apps

popular workflows

Page 475: Using Git to Manage and Deploy Rails Apps

central repository model

Page 476: Using Git to Manage and Deploy Rails Apps

developerdeveloper

developer

shared repositorydeveloper

developer

developer

developerdeveloper

developer

Page 477: Using Git to Manage and Deploy Rails Apps

developer

shared repository

developer developer

git clone

Page 478: Using Git to Manage and Deploy Rails Apps

developer

shared repository

developer developer

git push

Page 479: Using Git to Manage and Deploy Rails Apps

developer

shared repository

developer developer

git push

Page 480: Using Git to Manage and Deploy Rails Apps

developer

shared repository

developer developer

Page 481: Using Git to Manage and Deploy Rails Apps

developer

shared repository

developer developer

git fetchgit merge

Page 482: Using Git to Manage and Deploy Rails Apps

developer

shared repository

developer developer

git push

Page 483: Using Git to Manage and Deploy Rails Apps

dictator and lieutenants model

Page 484: Using Git to Manage and Deploy Rails Apps

developerdeveloper

dictator

developer

lieutenant

blessed repository

developer

lieutenant

Page 485: Using Git to Manage and Deploy Rails Apps

developerdeveloper

dictator

developer

lieutenant

blessed repository

developer

lieutenant

git clone

Page 486: Using Git to Manage and Deploy Rails Apps

developerdeveloper

dictator

developer

lieutenant

blessed repository

developer

lieutenant

git fetchgit merge

Page 487: Using Git to Manage and Deploy Rails Apps

developerdeveloper

dictator

developer

lieutenant

blessed repository

developer

lieutenant

git fetchgit merge

Page 488: Using Git to Manage and Deploy Rails Apps

developerdeveloper

dictator

developer

lieutenant

blessed repository

developer

lieutenant

git fetch; git merge

Page 489: Using Git to Manage and Deploy Rails Apps

developerdeveloper

dictator

developer

lieutenant

blessed repository

developer

lieutenant

git push

Page 490: Using Git to Manage and Deploy Rails Apps

developerdeveloper

dictator

developer

lieutenant

blessed repository

developer

lieutenant

git fetch

Page 491: Using Git to Manage and Deploy Rails Apps

integration manager model

Page 492: Using Git to Manage and Deploy Rails Apps

developerpublic

developerpublic

integration manager

blessedrepository

developerprivate

developerprivate

Page 493: Using Git to Manage and Deploy Rails Apps

developerpublic

developerpublic

integration manager

blessedrepository

developerprivate

developerprivate

github.com/schacon/ticgit

/yob/ticgit /pope/ticgit

Page 494: Using Git to Manage and Deploy Rails Apps

developerpublic

developerpublic

integration manager

blessedrepository

developerprivate

developerprivate

github.com/schacon/ticgit

/yob/ticgit /pope/ticgit“forks”

Page 495: Using Git to Manage and Deploy Rails Apps

developerpublic

developerpublic

integration manager

blessedrepository

developerprivate

developerprivate

git push

Page 496: Using Git to Manage and Deploy Rails Apps

developerpublic

developerpublic

integration manager

blessedrepository

developerprivate

developerprivate

git clone

Page 497: Using Git to Manage and Deploy Rails Apps

developerpublic

developerpublic

integration manager

blessedrepository

developerprivate

developerprivate

git push

Page 498: Using Git to Manage and Deploy Rails Apps

developerpublic

developerpublic

integration manager

blessedrepository

developerprivate

developerprivate

git fetchgit merge

Page 499: Using Git to Manage and Deploy Rails Apps

developerpublic

developerpublic

integration manager

blessedrepository

developerprivate

developerprivate

git push

Page 500: Using Git to Manage and Deploy Rails Apps

developerpublic

developerpublic

integration manager

blessedrepository

developerprivate

developerprivate

git fetchgit rebase / merge

Page 501: Using Git to Manage and Deploy Rails Apps

developerpublic

developerpublic

integration manager

blessedrepository

developerprivate

developerprivate

git push

Page 502: Using Git to Manage and Deploy Rails Apps

How Do I Deploy with Git?

Page 503: Using Git to Manage and Deploy Rails Apps

2m Who is Scott?

What is Git?

How Does Git Work?

How Do I Use Git?

2m This Slide

3m

20m

12m

How Do I Deploy with Git?4m

Where Can I Learn More?2m

75%

35 min

15%

6 min

10%

4 min

4m How Do I Deploy with Git?15%

6 min

Page 504: Using Git to Manage and Deploy Rails Apps

capistrano + git

Page 505: Using Git to Manage and Deploy Rails Apps

deploy.rb

Page 506: Using Git to Manage and Deploy Rails Apps

deploy.rb

Page 507: Using Git to Manage and Deploy Rails Apps

deploy.rb

Page 508: Using Git to Manage and Deploy Rails Apps
Page 509: Using Git to Manage and Deploy Rails Apps
Page 510: Using Git to Manage and Deploy Rails Apps
Page 511: Using Git to Manage and Deploy Rails Apps

other cap options

set :branch, "master"

set :git_shallow_clone, 1

set :git_enable_submodules, 1

Page 512: Using Git to Manage and Deploy Rails Apps

ruby + git

Page 513: Using Git to Manage and Deploy Rails Apps

ruby + git

grit

git gem

git-ruby

Page 514: Using Git to Manage and Deploy Rails Apps

ruby + git

grit

git gem

git-ruby

Page 515: Using Git to Manage and Deploy Rails Apps
Page 516: Using Git to Manage and Deploy Rails Apps
Page 517: Using Git to Manage and Deploy Rails Apps

github.com/schacon/ruby-git

Page 518: Using Git to Manage and Deploy Rails Apps

Where Can I Learn More?

Page 519: Using Git to Manage and Deploy Rails Apps

2m Who is Scott?

What is Git?

How Does Git Work?

How Do I Use Git?

2m This Slide

3m

20m

12m

How Do I Deploy with Git?4m

Where Can I Learn More?2m

75%

35 min

15%

6 min

10%

4 min

2m Where Can I Learn More?

15%

6 min

Page 520: Using Git to Manage and Deploy Rails Apps

Resourcesgit.or.cz

gitcasts.com

del.icio.us/popular/git

#git / #github on IRC

peepcode - git book and screencast

[email protected]

me. here.

Page 521: Using Git to Manage and Deploy Rails Apps

thats it!

Page 522: Using Git to Manage and Deploy Rails Apps

thats it!

gitcasts.com/git-talknotes, these slides, etc

Page 523: Using Git to Manage and Deploy Rails Apps

thats it!

gitcasts.com/git-talknotes, these slides, etc

git.or.cz

gitcasts.com

del.icio.us/popular/git

#git / #github on IRC

peepcode

[email protected]