Top Banner
1 Copyright ©2012 CollabNet, Inc. All Rights Reserved. ENTERPRISE CLOUD DEVELOPMENT Go Agile with Git (Part 1 of 3) Workflows, Branching & Merging Luca Milanesio [email protected] January 2013
27

Go Agile with Git (Part 1 of 3) Workflows, Branching & Merging · PDF fileGo Agile with Git (Part 1 of 3) Workflows, Branching & Merging Luca Milanesio ... Enterprise code-review...

Feb 14, 2018

Download

Documents

nguyenlien
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Go Agile with Git (Part 1 of 3) Workflows, Branching & Merging · PDF fileGo Agile with Git (Part 1 of 3) Workflows, Branching & Merging Luca Milanesio ... Enterprise code-review workflow

1 Copyright ©2012 CollabNet, Inc. All Rights Reserved. ENTERPRISE CLOUD DEVELOPMENT

Go Agile with Git (Part 1 of 3) Workflows, Branching & Merging

Luca Milanesio

[email protected] January 2013

Page 2: Go Agile with Git (Part 1 of 3) Workflows, Branching & Merging · PDF fileGo Agile with Git (Part 1 of 3) Workflows, Branching & Merging Luca Milanesio ... Enterprise code-review workflow

2 Copyright ©2012 CollabNet, Inc. All Rights Reserved.

Luca Milanesio

Luca Milanesio is Director and cofounder of GerritForge LLP, the leader Git and Gerrit competence center

for the Enterprise and key technology partner of CollabNet Inc. His background includes 20 years of

experience in development management, software configuration management and software development

lifecycle in large Enterprises worldwide. Just prior to GerritForge LLP, Luca was Technical Director and Senior

Product of the Security and Compliance platform for Electronic Payments at Primeur in Italy and UK. Since

starting GerritForge LLP, Luca contributed to the Gerrit community and allowed the introduction of

Enterprise code-review workflow in large Enterprises worldwide. Thanks to GerritForge LLP and CollabNet

Inc. TeamForge is now the most advanced ALM platform with integrated Git support and Code-Review for

the Enterprise.

About the Speaker

About CollabNet

• Industry leader in Enterprise Cloud Development (ECD)

• Agile ALM, DevOps, SCM, Git & SVN – Product & Services

• Download TeamForge for FREE @ www.collab.net/git

Page 3: Go Agile with Git (Part 1 of 3) Workflows, Branching & Merging · PDF fileGo Agile with Git (Part 1 of 3) Workflows, Branching & Merging Luca Milanesio ... Enterprise code-review workflow

3 Copyright ©2012 CollabNet, Inc. All Rights Reserved.

Agenda

• Introduction and Git concepts

• Gerrit explained

• Gerrit and Jenkins integration

• Q&A

Page 4: Go Agile with Git (Part 1 of 3) Workflows, Branching & Merging · PDF fileGo Agile with Git (Part 1 of 3) Workflows, Branching & Merging Luca Milanesio ... Enterprise code-review workflow

4 Copyright ©2012 CollabNet, Inc. All Rights Reserved.

Introduction and Concepts

• Git

– Most popular emerging distributed SCM

• Jenkins

– Most popular open source Continuous Integration

• Gerrit Code Review

– Widely used code-review based on Git

• CollabNet® TeamForge®

– Provides an unparalleled smooth integration of all these tools into your software development process

Page 5: Go Agile with Git (Part 1 of 3) Workflows, Branching & Merging · PDF fileGo Agile with Git (Part 1 of 3) Workflows, Branching & Merging Luca Milanesio ... Enterprise code-review workflow

5 Copyright ©2012 CollabNet, Inc. All Rights Reserved. 5 Copyright ©2012 CollabNet, Inc. All Rights Reserved.

Understanding Git “Git is a distributed revision control and source code management (SCM) system with an emphasis on speed. Git was initially designed and developed by Linus Torvalds for Linux kernel development; it has since been adopted by many other projects. […] Git is free software distributed under the terms of the GNU General Public License version 2.”

source: Wikipedia

Page 6: Go Agile with Git (Part 1 of 3) Workflows, Branching & Merging · PDF fileGo Agile with Git (Part 1 of 3) Workflows, Branching & Merging Luca Milanesio ... Enterprise code-review workflow

6 Copyright ©2012 CollabNet, Inc. All Rights Reserved.

• Open source distributed SCM, used notably by:

– Linux (it was originally developed for that very purpose)

– Eclipse foundation

– Android (based on Gerrit Code Review)

• Why Git?

– All operations are local

• search, log, history, branching and merging

• offline development is possible

– Powerful merging strategies (merge, rebase, cherry-pick)

• CollabNet® TeamForge® provides a seamless and secure Git support out-of-the-box

What is Git Today?

Page 7: Go Agile with Git (Part 1 of 3) Workflows, Branching & Merging · PDF fileGo Agile with Git (Part 1 of 3) Workflows, Branching & Merging Luca Milanesio ... Enterprise code-review workflow

7 Copyright ©2012 CollabNet, Inc. All Rights Reserved.

Commit Graph and UUIDs

commit

fd002

commit

bd986

commit

e10ca

snapshot

master

snapshot snapshot

• Commits are identified with a SHA-1 UUID

– Repository history is a graph of linked commits

– Commit points to a "object tree" of content

– Branch or Tag = label of a point in the history

Page 8: Go Agile with Git (Part 1 of 3) Workflows, Branching & Merging · PDF fileGo Agile with Git (Part 1 of 3) Workflows, Branching & Merging Luca Milanesio ... Enterprise code-review workflow

8 Copyright ©2012 CollabNet, Inc. All Rights Reserved.

Merging Code – Recursive Merge

C3 C1

master

C4 C5

C6 C7

work

• Join history of two development streams

– Similar to SVN merge

– Merge is tracked as commit in the repository

master

work

C8

Page 9: Go Agile with Git (Part 1 of 3) Workflows, Branching & Merging · PDF fileGo Agile with Git (Part 1 of 3) Workflows, Branching & Merging Luca Milanesio ... Enterprise code-review workflow

9 Copyright ©2012 CollabNet, Inc. All Rights Reserved.

Merging Code – Cherry-pick

• Apply individual commits on another branch

– Choose individual changes and apply anywhere

– Keep original history of changes

C3 C1

master

C4 C5

C6 C7 work

master

C6’ C7’

Page 10: Go Agile with Git (Part 1 of 3) Workflows, Branching & Merging · PDF fileGo Agile with Git (Part 1 of 3) Workflows, Branching & Merging Luca Milanesio ... Enterprise code-review workflow

10 Copyright ©2012 CollabNet, Inc. All Rights Reserved.

Merging Code – Rebase

• Apply changes on another history branch

– Branches flattened up

– History on rebased branch is rewritten

C3 C1

master

C4 C5

C6 C7

work

C6’ C7’

master

work

Page 11: Go Agile with Git (Part 1 of 3) Workflows, Branching & Merging · PDF fileGo Agile with Git (Part 1 of 3) Workflows, Branching & Merging Luca Milanesio ... Enterprise code-review workflow

11 Copyright ©2012 CollabNet, Inc. All Rights Reserved.

• Git code-merging strategies summary – Recursive merge

– Branch rebase

– Cherry-pick

• Other code merging strategies – Criss-cross, octopus, ours, subtree merge

– Squashing commits and interactive rebase

– Learn more at: http://www.slideshare.net/lucamilanesio/git-workshop-33degree-2011-krakow

• Enterprise grade Git with CollabNet TeamForge® – TeamForge history protection webinar

http://visit.collab.net/2012Q4WebinarFirstintheIndustryCollabNetprovidesHistoryProtectionforGit_WebinarRegistration.html

– Git for the Enterprise webinar http://visit.collab.net/webinar-git-enterprise.html

More about Branching and History Protection

Page 12: Go Agile with Git (Part 1 of 3) Workflows, Branching & Merging · PDF fileGo Agile with Git (Part 1 of 3) Workflows, Branching & Merging Luca Milanesio ... Enterprise code-review workflow

12 Copyright ©2012 CollabNet, Inc. All Rights Reserved.

1. Git

2. Subversion

3. Perforce

4. ClearCase

5. Two or more from the above list

Poll: what SCM is mainly used in your Enterprise ?

Page 13: Go Agile with Git (Part 1 of 3) Workflows, Branching & Merging · PDF fileGo Agile with Git (Part 1 of 3) Workflows, Branching & Merging Luca Milanesio ... Enterprise code-review workflow

13 Copyright ©2012 CollabNet, Inc. All Rights Reserved.

• Git is the key enabler for Team Agility

– Everything is local

– Commit early, commit often

– Work beautifully with Continuous Integration (Jenkins)

• Enablement of branching and remote repository

– Local development branches

– Allows different history on remote sites

– Push / pull synchronization across repositories

• Merging strategies

– Designed for merging code consistently

– Embedded merge-tracking

– Rebase and cherry-pick code across branches

Summary

Page 14: Go Agile with Git (Part 1 of 3) Workflows, Branching & Merging · PDF fileGo Agile with Git (Part 1 of 3) Workflows, Branching & Merging Luca Milanesio ... Enterprise code-review workflow

14 Copyright ©2012 CollabNet, Inc. All Rights Reserved. 14 Copyright ©2012 CollabNet, Inc. All Rights Reserved.

Gerrit Code Review “Gerrit is a free, web-based team software code review tool that integrates with Git version control software. It has been developed at Google […] for the development of the Android project. As it is web based, software developers in a team can review each other's modifications on their source code using a web browser and approve or reject those changes.”

source: Wikipedia

Page 15: Go Agile with Git (Part 1 of 3) Workflows, Branching & Merging · PDF fileGo Agile with Git (Part 1 of 3) Workflows, Branching & Merging Luca Milanesio ... Enterprise code-review workflow

15 Copyright ©2012 CollabNet, Inc. All Rights Reserved.

• 100% pure Java SSH and HTTP Git backend

– Scalable and suitable for large Enterprises

• Web-based and Command Line administration

– Users and Groups

– Project and branch security

• Collaboration and Code-review

– B2B integration at code-level

– Communicate and share code knowledge in the Team

– Enforce workflow and code quality

• The most successful open source code review

– Android OS

– Eclipse, OpenStack, CouchDB and many others

What is Gerrit Today?

Page 16: Go Agile with Git (Part 1 of 3) Workflows, Branching & Merging · PDF fileGo Agile with Git (Part 1 of 3) Workflows, Branching & Merging Luca Milanesio ... Enterprise code-review workflow

16 Copyright ©2012 CollabNet, Inc. All Rights Reserved.

1. Not at all

2. Heard of it but never used

3. Tried at least once

4. We are experimenting internally

5. We use it on a daily basis

Poll: Are You Familiar with Gerrit Code Review ?

Page 17: Go Agile with Git (Part 1 of 3) Workflows, Branching & Merging · PDF fileGo Agile with Git (Part 1 of 3) Workflows, Branching & Merging Luca Milanesio ... Enterprise code-review workflow

17 Copyright ©2012 CollabNet, Inc. All Rights Reserved.

Who's Using Gerrit in Production Today ?

source: Wikipedia

Page 18: Go Agile with Git (Part 1 of 3) Workflows, Branching & Merging · PDF fileGo Agile with Git (Part 1 of 3) Workflows, Branching & Merging Luca Milanesio ... Enterprise code-review workflow

18 Copyright ©2012 CollabNet, Inc. All Rights Reserved.

• Early bug discovery – Four eyes catch the bug

– More time reading code and less new bugs

• Collective code ownership – Entire team is responsible for a change

– Trigger discussion on code and architecture

• Enforce code and quality standards – Avoid broken builds by enforcing quality first

– Automatically check your company coding standards

• Build a trust model on teams – Delegate the approval process

– Allow "elected roles promotion" and make people feeling engaged

Goals of Gerrit Code Review

Page 19: Go Agile with Git (Part 1 of 3) Workflows, Branching & Merging · PDF fileGo Agile with Git (Part 1 of 3) Workflows, Branching & Merging Luca Milanesio ... Enterprise code-review workflow

19 Copyright ©2012 CollabNet, Inc. All Rights Reserved.

• Project

– Git repository created and managed by Gerrit

– Group members and ACLs

– Track changes (all, including un-merged) and reviews

– Can merge code into the project branches

Gerrit: Concepts

• ALM Project entry point – Aggregates Code Review projects

together

– Define members and roles

– Allows bi-directional tracking on your artifacts

– Define templates of review workflows

Page 20: Go Agile with Git (Part 1 of 3) Workflows, Branching & Merging · PDF fileGo Agile with Git (Part 1 of 3) Workflows, Branching & Merging Luca Milanesio ... Enterprise code-review workflow

20 Copyright ©2012 CollabNet, Inc. All Rights Reserved.

•Contributor

– Propose changes and new ideas

•Reviewer

– Discuss and vote: -1 (things to improve) to +1 (looks good)

•Committer

– Permanent member of the project

– Validate changes, from -1 (doesn't work) to +1 (works)

– Can veto (-2) or approve (+2) a change

– Can merge code into the project branches

Gerrit: Project Roles

Page 21: Go Agile with Git (Part 1 of 3) Workflows, Branching & Merging · PDF fileGo Agile with Git (Part 1 of 3) Workflows, Branching & Merging Luca Milanesio ... Enterprise code-review workflow

21 Copyright ©2012 CollabNet, Inc. All Rights Reserved.

• Change

• Patch Set

• Review

Code Review Glossary

Commit submitted for review

Set of changes made on a change

Scoring of a change based on a patch set

-2: veto, do not merge -1: it's OK, more patches needed 0: just comments, no score +1: it's OK, but I need somebody else to look at it +2: it's perfect, please merge

Verification if a change works or not

Submit change through the GUI

Accept a change and push it through Git

Do not merge the change and park it indefinitely

• Verified

• Submit change

• Merge change

• Abandon change

Page 22: Go Agile with Git (Part 1 of 3) Workflows, Branching & Merging · PDF fileGo Agile with Git (Part 1 of 3) Workflows, Branching & Merging Luca Milanesio ... Enterprise code-review workflow

22 Copyright ©2012 CollabNet, Inc. All Rights Reserved.

• Gerrit workflow overview

• Working with TeamForge and Gerrit

• Adding team members to a project

• Hands-on and Gerrit live on TeamForge 6.2

Coming in the Next Session

Page 23: Go Agile with Git (Part 1 of 3) Workflows, Branching & Merging · PDF fileGo Agile with Git (Part 1 of 3) Workflows, Branching & Merging Luca Milanesio ... Enterprise code-review workflow

23 Copyright ©2012 CollabNet, Inc. All Rights Reserved.

• TeamForge + Gerrit is a powerful foundation for Enterprise Git

• Git provides the ability to improve speed and agility over distributed Teams

• Git is able to combine changes from different repos and branches thanks advanced merge strategies and commands

• TeamForge provides history protection on top of to ensures that potentially unnoticed events, such as remote branch deletions and forced pushes, are now detected and fully recoverable.

• Gerrit and TeamForge organise Git repository and Code Review lifecycle artifacts into a single project space

Summary

Page 25: Go Agile with Git (Part 1 of 3) Workflows, Branching & Merging · PDF fileGo Agile with Git (Part 1 of 3) Workflows, Branching & Merging Luca Milanesio ... Enterprise code-review workflow

25 Copyright ©2012 CollabNet, Inc. All Rights Reserved. 25 Copyright ©2012 CollabNet, Inc. All Rights Reserved.

Questions?

Luca Milanesio

[email protected] www.collab.net +1-650-228-2500 +1-888-778-9793 blogs.collab.net twitter.com/collabnet www.facebook.com/collabnet www.linkedin.com/company/collabnet-inc

Page 26: Go Agile with Git (Part 1 of 3) Workflows, Branching & Merging · PDF fileGo Agile with Git (Part 1 of 3) Workflows, Branching & Merging Luca Milanesio ... Enterprise code-review workflow

26 Copyright ©2012 CollabNet, Inc. All Rights Reserved. 26 Copyright ©2012 CollabNet, Inc. All Rights Reserved.

About CollabNet

CollabNet is a leading provider of Enterprise Cloud Development and Agile ALM products and services for software-driven organizations. With more than 10,000 global customers, the company provides a suite of platforms and services to address three major trends disrupting the software industry: Agile, DevOps and hybrid cloud development. Its CloudForge™ development-Platform-as-a-Service (dPaaS) enables cloud development through a flexible platform that is team friendly, enterprise ready and integrated to support leading third party tools. The CollabNet TeamForge® ALM, ScrumWorks® Pro project management and SubversionEdge source code management platforms can be deployed separately or together, in the cloud or on-premise. CollabNet complements its technical offerings with industry leading consulting and training services for Agile and cloud development transformations. Many CollabNet customers improve productivity by as much as 70 percent, while reducing costs by 80 percent.

For more information, please visit www.collab.net.

Page 27: Go Agile with Git (Part 1 of 3) Workflows, Branching & Merging · PDF fileGo Agile with Git (Part 1 of 3) Workflows, Branching & Merging Luca Milanesio ... Enterprise code-review workflow

27 Copyright ©2012 CollabNet, Inc. All Rights Reserved. 27 Copyright ©2012 CollabNet, Inc. All Rights Reserved.

© 2012 CollabNet, Inc., All rights reserved. CollabNet is a trademark or registered trademark of CollabNet Inc., in the US and other countries. All other trademarks, brand names, or product names belong to their respective holders.

CollabNet, Inc. 8000 Marina Blvd., Suite 600 Brisbane, CA 94005 www.collab.net +1-650-228-2500 +1-888-778-9793 blogs.collab.net twitter.com/collabnet www.facebook.com/collabnet www.linkedin.com/company/collabnet-inc