+ All Categories
Home > Documents > Introducing Git version control into your team

Introducing Git version control into your team

Date post: 23-Feb-2016
Category:
Upload: dai
View: 38 times
Download: 0 times
Share this document with a friend
Description:
Introducing Git version control into your team. Mark Groves [email protected] @mgroves84 . Agenda. Introduction What is Git? Git 101 Enabling Team Development Short vs. Long Lived Branches Deploying with Git Your Org uses TFS? Tools/Resources. WHO AM I?. Mark Groves - PowerPoint PPT Presentation
Popular Tags:
137
patterns & practices Symposium 2013 Introducing Git version control into your team Mark Groves [email protected] @mgroves84
Transcript
Page 1: Introducing Git version control into your team

patterns & practices Symposium 2013

Introducing Git version control into your team

Mark [email protected]

@mgroves84

Page 2: Introducing Git version control into your team

Symposium 2013

Agenda Introduction What is Git? Git 101 Enabling Team Development Short vs. Long Lived Branches Deploying with Git Your Org uses TFS? Tools/Resources

Page 3: Introducing Git version control into your team

WHO AM I?Mark GrovesPrincipal Program ManagerDeveloper Division

Page 4: Introducing Git version control into your team
Page 5: Introducing Git version control into your team
Page 6: Introducing Git version control into your team

History

Page 7: Introducing Git version control into your team

HistoryCreated by Linus Torvalds for work on the Linux kernel ~2005

Page 8: Introducing Git version control into your team

HistoryCreated by Linus Torvalds for work on the Linux kernel ~2005Some of the companies that use git:

Page 9: Introducing Git version control into your team

What is Git?

Page 10: Introducing Git version control into your team

Git is aDistributedVersion Control System

Page 11: Introducing Git version control into your team

OR

Page 12: Introducing Git version control into your team

Git is a

DirectoryContent Management System

Page 13: Introducing Git version control into your team

Git is a

history storage system

Tree

Page 14: Introducing Git version control into your team

Git is a

content trackerStupid

Page 15: Introducing Git version control into your team

How ever you think about it…

Page 16: Introducing Git version control into your team

How ever you think about it…

Git is SUPER cool

Page 17: Introducing Git version control into your team

DistributedEveryone has the complete history

Page 18: Introducing Git version control into your team

Distributed

Everything is done offline

…except push/pull

Everyone has the complete history

Page 19: Introducing Git version control into your team

Distributed

Everything is done offlineEveryone has the complete history

No central authority

…except by convention

Page 20: Introducing Git version control into your team

Distributed

Everything is done offlineEveryone has the complete history

No central authorityChanges can be shared without a server

Page 21: Introducing Git version control into your team

Centralized VC vs. Distributed VC

Central Server Remote Server

Page 22: Introducing Git version control into your team

Branching

Page 23: Introducing Git version control into your team

BranchingForget what you know from Central VC(…TFS, SVN, Perforce...)

Page 24: Introducing Git version control into your team

BranchingForget what you know from Central VCGit branch is “Sticky Note” on a graph node

Page 25: Introducing Git version control into your team

BranchingForget what you know from Central VCGit branch is “Sticky Note” on a graph nodeAll branch work takes place within the same folder within your file system.

Page 26: Introducing Git version control into your team

BranchingForget what you know from Central VCGit branch is “Sticky Note” on the graphAll branch work takes place within the same folder within your file system. When you switch branches you are moving the “Sticky Note”

Page 27: Introducing Git version control into your team

InitializationC:\> mkdir CoolProjectC:\> cd CoolProjectC:\CoolProject > git initInitialized empty Git repository in C:/CoolProject/.gitC:\CoolProject > notepad README.txtC:\CoolProject > git add .C:\CoolProject > git commit -m 'my first commit'[master (root-commit) 7106a52] my first commit 1 file changed, 1 insertion(+) create mode 100644 README.txt

Page 28: Introducing Git version control into your team

Branches Illustrated

masterA

> git commit –m ‘my first commit’

Page 29: Introducing Git version control into your team

Branches Illustrated

master

> git commit (x2)

A B C

Page 30: Introducing Git version control into your team

Branches Illustrated

bug123

master

> git checkout –b bug123

A B C

Page 31: Introducing Git version control into your team

Branches Illustrated

master

> git commit (x2)

A B CD E

bug123

Page 32: Introducing Git version control into your team

Branches Illustrated

master

> git checkout master

A B CD E

bug123

Page 33: Introducing Git version control into your team

Branches Illustrated

bug123

master

> git merge bug123

A B C D E

Page 34: Introducing Git version control into your team

Branches Illustrated

master

> git branch -d bug123

A B C D E

Page 35: Introducing Git version control into your team

Branches Illustrated

masterA B C D E

F Gbug45

6

Page 36: Introducing Git version control into your team

Branches Illustrated

masterA B C D E

F Gbug45

6> git checkout master

Page 37: Introducing Git version control into your team

Branches Illustrated

masterA B C D E

F G

> git merge bug456

H

bug456

Page 38: Introducing Git version control into your team

Branches Illustrated

masterA B C D E

F G

> git branch -d bug456

H

Page 39: Introducing Git version control into your team

Branches Illustrated

masterA B C D E

F Gbug45

6

Page 40: Introducing Git version control into your team

Branches Illustrated

masterA B C D E

> git rebase master

F’ G’ bug45

6

Page 41: Introducing Git version control into your team

Branches Illustrated

masterA B C D E

> git checkout master> git merge bug456

F’ G’ bug45

6

Page 42: Introducing Git version control into your team

Branching Review

Page 43: Introducing Git version control into your team

Branching ReviewQuick and Easy to create ‘Feature’ Branches

Page 44: Introducing Git version control into your team

Branching Review

Local branches are very powerfulQuick and Easy to create ‘Feature’ Branches

Page 45: Introducing Git version control into your team

Branching Review

Local branches are very powerfulQuick and Easy to create ‘Feature’ BranchesRebase is not scary

Page 46: Introducing Git version control into your team

Software is a Team Sport

Page 47: Introducing Git version control into your team

Sharing commits

My Local Repo

Tom’s Repo

Tracey’s Repo

Matt’s Repo

A B C

A B C A B C

A B C

Page 48: Introducing Git version control into your team

Adding a Remote

Page 49: Introducing Git version control into your team

Sharing commits

My Local Repo

Tom’s Repo

Tracey’s Repo

Matt’s Repo

A B C

A B C A B C

A B C

Remote RepoA B C

D

D

D

D

D

Page 50: Introducing Git version control into your team

Setting up a Remote

Page 51: Introducing Git version control into your team

Setting up a RemoteAdding a remote to an existing local repoC:\CoolProject > git remote add origin

https://git01.codeplex.com/coolprojectC:\CoolProject > git remote -vorigin https://git01.codeplex.com/coolproject (fetch)origin https://git01.codeplex.com/coolproject (push)

Page 52: Introducing Git version control into your team

Setting up a RemoteClone will auto setup the remote

C:\> git clone https://git01.codeplex.com/coolprojectCloning into 'coolproject'...remote: Counting objects: 3, done.remote: Total 3 (delta 0), reused 0 (delta 0)Unpacking objects: 100% (3/3), done.C:\> cd .\coolprojectC:\CoolProject> git remote -vorigin https://git01.codeplex.com/coolproject (fetch)origin https://git01.codeplex.com/coolproject (push)

Page 53: Introducing Git version control into your team

Setting up a RemoteName remotes what you want

Page 54: Introducing Git version control into your team

Setting up a RemoteName remotes what you wantOrigin is only a convention

Page 55: Introducing Git version control into your team

Branches Illustrated

Amaster

B C D Ebug12

3

Page 56: Introducing Git version control into your team

Branches Illustrated

Amaster

origin/master

B C D Ebug12

3

Page 57: Introducing Git version control into your team

Branches Illustrated

AB C D E

master

bug123

origin/master

Page 58: Introducing Git version control into your team

Branches Illustrated

AB C D E

master

bug123

F G

origin/master

origin/master

Page 59: Introducing Git version control into your team

Branches Illustrated

AB C D E

master

bug123

> git checkout master

origin/master

Page 60: Introducing Git version control into your team

Branches Illustrated

AB C D E

master

bug123

F G

> git pull origin

origin/master

Page 61: Introducing Git version control into your team

Pull = Fetch + MergeFetch - updates your local copy of the remote branch

Pull essentially does a fetch and then runs the merge in one step.

Page 62: Introducing Git version control into your team

Branches Illustrated

AB C D E

master

bug123

F G

origin/master

Page 63: Introducing Git version control into your team

Branches Illustrated

AB C D E

master

bug123

F G

> git checkout bug123

origin/master

Page 64: Introducing Git version control into your team

Branches Illustrated

AB’

C’

D’

E’

master

bug123

F G

> git rebase master

origin/master

Page 65: Introducing Git version control into your team

Branches Illustrated

AB’

C’

D’

E’

master

bug123

F G

> git checkout master

origin/master

Page 66: Introducing Git version control into your team

Branches Illustrated

Amaster

bug123

F G

> git merge bug123

B’

C’

D’

E’

origin/master

Page 67: Introducing Git version control into your team

Branches Illustrated

Amaster

F G

> git push origin

B’

C’

D’

E’ bug12

3

origin/master

Page 68: Introducing Git version control into your team

PushPushes your changes upstream

Git will reject pushes if newer changes exist on remote.

Good practice: Pull then Push

Page 69: Introducing Git version control into your team

Branches Illustrated

Amaster

F G B’

C’

D’

E’ bug12

3

origin/master

Page 70: Introducing Git version control into your team

Branches Illustrated

Amaster

F G

> git branch -d bug123

B’

C’

D’

E’

origin/master

Page 71: Introducing Git version control into your team

Adding a Remote ReviewAdding a remote makes it easy to share

Pulling from the remote often helps keep you up to date

Page 72: Introducing Git version control into your team

Short vs. Long-Lived BranchesLocal branches are short lived

Page 73: Introducing Git version control into your team

Short vs. Long-Lived BranchesLocal branches are short livedStaying off master keeps merges simple

Page 74: Introducing Git version control into your team

Short vs. Long-Lived BranchesLocal branches are short livedStaying off master keeps merges simpleEnables working on several changes at once

Page 75: Introducing Git version control into your team

Short vs. Long-Lived BranchesLocal branches are short livedStaying off master keeps merges simpleEnables working on several changes at onceCreate

Commit

Merge

Delete

Page 76: Introducing Git version control into your team

Short vs. Long-Lived BranchesGreat for multi-version work

Page 77: Introducing Git version control into your team

Short vs. Long-Lived BranchesGreat for multi-version workFollow same rules as Master

Page 78: Introducing Git version control into your team

Short vs. Long-Lived BranchesGreat for multi-version workFollow same rules as Master…Story branches

Page 79: Introducing Git version control into your team

Short vs. Long-Lived BranchesGreat for multi-version workFollow same rules as Master…Story branchesIntegrate frequently

Page 80: Introducing Git version control into your team

Short vs. Long-Lived BranchesGreat for multi-version workFollow same rules as Master…Story branchesIntegrate frequentlyPushed to Remotes

Page 81: Introducing Git version control into your team

Branches Illustrated

Emaster

origin/master

Page 82: Introducing Git version control into your team

Branches Illustrated

Emaster

origin/master

develop

> git branch develop

Page 83: Introducing Git version control into your team

Branches Illustrated

Emaster

origin/master

develop

> git push origin develop

origin/develop

Page 84: Introducing Git version control into your team

Branches Illustrated

Emaster

origin/master

develop

> git checkout develop

origin/develop

Page 85: Introducing Git version control into your team

Branches Illustrated

Emaster

origin/master

F Gdevelo

p origin/develop

Page 86: Introducing Git version control into your team

Branches Illustrated

Emaster

origin/master

F Gdevelo

porigin/develop

> git pull origin develop

Page 87: Introducing Git version control into your team

Branches Illustrated

Emaster

origin/master

F Gdevelo

porigin/develop

> git checkout –b ideaidea

Page 88: Introducing Git version control into your team

Branches Illustrated

Emaster

origin/master

F Gdevelo

porigin/develop

> git commitidea

H

Page 89: Introducing Git version control into your team

Branches Illustrated

E

origin/master

F Gorigin/

develop idea

HI

master

develop

Page 90: Introducing Git version control into your team

Branches Illustrated

E

origin/master

F Gorigin/

develop idea

H

master

develop

> git pull (at least daily)

I

Page 91: Introducing Git version control into your team

Branches Illustrated

E

origin/master

F Gorigin/

develop idea

H

master

> git checkout develop

I

develop

Page 92: Introducing Git version control into your team

Branches Illustrated

E

origin/master

F Gorigin/

develop idea

H

master

> git merge idea (fast forward merge)

I

develop

Page 93: Introducing Git version control into your team

Branches Illustrated

E

origin/master

F Gorigin/

develop

H

master

> git branch –d idea

I

develop

Page 94: Introducing Git version control into your team

Branches Illustrated

E

origin/master

F Gorigin/

develop

H

master

> git push origin develop

I

develop

Page 95: Introducing Git version control into your team

Merge Flow vs. Rebase Flow

E

origin/master

F Gorigin/

develop

H

master

> git push origin develop

I

develop

Page 96: Introducing Git version control into your team

Branches Illustrated – Merge Flow

E

origin/master

F Gorigin/

develop

H

master

> git checkout master

I

develop

Page 97: Introducing Git version control into your team

Branches Illustrated – Merge Flow

E

origin/master

F Gorigin/

develop

H

master

> git merge develop

I

develop

J

Page 98: Introducing Git version control into your team

Branches Illustrated – Merge Flow

E

origin/master

F Gorigin/

develop

H

master

> git push origin

I

develop

J

Page 99: Introducing Git version control into your team

Branches Illustrated – Rebase Flow

E

origin/master

F Gorigin/

develop

H

master

> git checkout master

I

develop

Page 100: Introducing Git version control into your team

Branches Illustrated – Rebase Flow

E

origin/master

F Gorigin/

develop

Hmaster

> git rebase develop

I’develo

p

I

Page 101: Introducing Git version control into your team

Branches Illustrated – Rebase Flow

E

origin/master

F Gorigin/

develop

Hmaster

> git push origin

I’develo

p

Page 102: Introducing Git version control into your team

Rebase FlowE

origin/master

F Gorigin/

develop

Hmaster

I’develo

p

E

origin/master

F Gorigin/

develop

H

masterI

develop

J

Merge Flow

Page 103: Introducing Git version control into your team

Short vs. Long-Lived BranchesGreat for multi-version workFollow same rules as Master

…use Story branchesDefine your conventions

What branches do you want to share?

Branch per environment?

Page 104: Introducing Git version control into your team

Deploying with Git

Page 105: Introducing Git version control into your team

Deploying with GitDeveloper “FTP”

Page 106: Introducing Git version control into your team

Deploying with GitDeveloper “FTP”Additional Branches pointing at:

Page 107: Introducing Git version control into your team

Deploying with GitDeveloper FTPAdditional Branches pointing at:

Test, Staging , Production

Page 108: Introducing Git version control into your team

Deploying with GitDeveloper FTPAdditional Branches pointing at:

Test, Staging , ProductionPost Commit Hooks Automate deployments

Page 109: Introducing Git version control into your team

Cloud Providers – Git SupportAppHarborHerokuNodejitsuWindows Azure… to name a few

Page 110: Introducing Git version control into your team

Simple Azure Deploy

Page 111: Introducing Git version control into your team
Page 112: Introducing Git version control into your team
Page 113: Introducing Git version control into your team
Page 114: Introducing Git version control into your team
Page 115: Introducing Git version control into your team
Page 116: Introducing Git version control into your team
Page 117: Introducing Git version control into your team
Page 118: Introducing Git version control into your team
Page 119: Introducing Git version control into your team
Page 120: Introducing Git version control into your team
Page 121: Introducing Git version control into your team

C:\CoolProject > git remote add azure https://[email protected]/coolproject.gitC:\CoolProject > git remote -vazure https://[email protected]/coolproject.git (fetch)azure https://[email protected]/coolproject.git (push)origin https://git01.codeplex.com/coolproject (fetch)origin https://git01.codeplex.com/coolproject (push)C:\CoolProject > git push azure masterCounting objects: 3, done.Writing objects: 100% (3/3), 226 bytes, done.Total 3 (delta 0), reused 0 (delta 0)remote: New deployment received.remote: Updating branch 'master'.remote: Updating submodules.remote: Preparing deployment for commit id '7106a52771'.remote: Preparing files for deployment.remote: Deployment successful.To https://[email protected]/coolproject.git * [new branch] master -> master

Page 122: Introducing Git version control into your team
Page 123: Introducing Git version control into your team

Git DeploymentSimple workflow

Page 124: Introducing Git version control into your team

Git DeploymentSimple workflowAdd Hooks to deploy on Commit

Page 125: Introducing Git version control into your team

Git DeploymentSimple workflowAdd Hooks to deploy on CommitCan get more advanced

Page 126: Introducing Git version control into your team

Git DeploymentSimple workflowAdd Hooks to deploy on CommitCan get more advancedAdd Build machines, push on success

Page 127: Introducing Git version control into your team

Your Org uses TFS?

Page 128: Introducing Git version control into your team

Your Org uses TFS? Sure Use Git-TFLocal workflow with Git

Page 129: Introducing Git version control into your team

Your Org uses TFS? Sure Use Git-TFLocal workflow with GitPush to TFS as a Remote

Page 130: Introducing Git version control into your team

Your Org uses TFS? Sure Use Git-TFLocal workflow with GitPush to TFS as a RemoteMulti-Platform and Open Source

Page 131: Introducing Git version control into your team

Your Org uses TFS? Sure Use Git-TFLocal workflow with GitPush to TFS as a RemoteMulti-Platform and Open Sourcehttp://gittf.codeplex.com

Page 132: Introducing Git version control into your team

Individual Developer WorkflowC:\CoolProject > git tf clone http://myserver:8080/tfs $/TeamProjectA/Main Make changes to the file in the Git repoC:\CoolProject > git commit -a -m "commit one" (commit changes locally) Make more changesC:\CoolProject > git commit -a -m "commit two"C:\CoolProject > git tf pull --rebaseC:\CoolProject > git tf checkin

Page 133: Introducing Git version control into your team

Git-TF for larger teamsTFS

Tom’s Repo

Tracey’s Repo

Matt’s Repo

A B C A B C A B C

Shared Git RepoA B C

git tf clone

git push

git clone git clone

Page 134: Introducing Git version control into your team

Git-TFLocal workflow with GitPush to TFS as a RemoteMulti-Platform and Open Sourcehttp://gittf.codeplex.com

Page 135: Introducing Git version control into your team

http://Git-SCM.com

Page 136: Introducing Git version control into your team

Tools / ResourcesPro Git (Book) http://www.git-scm.com/book

TortoiseGit (with TortoiseMerge) http://code.google.com/p/tortoisegitMsysgit (includes git-bash) http://code.google.com/p/msysgit

Posh-Git (for PowerShell users) http://github.com/dahlbyk/posh-git

GitScc (Visual Studio integration) http://gitscc.codeplex.com/

Windows Git Credential Store http://gitcredentialstore.codeplex.com/

GitHub for Windows http://windows.github.com/

Page 137: Introducing Git version control into your team

Symposium 2013

[email protected]@mgroves84


Recommended