28
Eclipse Hacker’s Guide to the Git Universe Tutorial EclipseCon 2011 http://eclipse.org/jgit http://eclipse.org/egit http://code.google.com/p/ gerrit Matthias Sohn (SAP) Stefan Lay (SAP) Chris Aniszczyk (Twitter) Kevin Sawicki (GitHub) Benjamin Muskalla (Tasktop) Sasa Zivkov(SAP) background photo courtesy of NASA http://www.nasa.gov/multimedia/guidelines/index.html

Eclipse Hacker's Guide to the Git Universe

  • Upload
    msohn

  • View
    2.026

  • Download
    3

Embed Size (px)

DESCRIPTION

Slides for Git Tutorial held at EclipseCon Europe 2011-11-02 in Ludwigsburg

Citation preview

Page 1: Eclipse Hacker's Guide to the Git Universe

Eclipse Hacker’sGuide to the Git Universe

Tutorial EclipseCon 2011

http://eclipse.org/jgithttp://eclipse.org/egit

http://code.google.com/p/gerrit

Matthias Sohn(SAP)

Stefan Lay(SAP)

Chris Aniszczyk(Twitter)

Kevin Sawicki(GitHub)

Benjamin Muskalla (Tasktop)

Sasa Zivkov(SAP)

background photo courtesy of NASA http://www.nasa.gov/multimedia/guidelines/index.html

Page 2: Eclipse Hacker's Guide to the Git Universe

Agenda

Introduction

Setup and Cloning the Sample RepositoryLocal Development with EGit

Gerrit Code ReviewMylyn IntegrationGitHub Eclipse Support

Q & A

Copyright © C. Aniszczyk, S. Lay, B. Muskalla, K. Sawicki, M. Sohn, S. Zivkov

Page 3: Eclipse Hacker's Guide to the Git Universe

Git… a distributed revision control system built by the Linux project to facilitate code review

Distributed means no central repository• No central authority!• Easy offline usage• Easy to branch a project• Protected against manipulation by cryptographic hashes

Really good at merging• Coordination only needed "after the fact”• Easier to rejoin (or refresh) branches

Structured around commits (i.e. patches)• Tools for identifying problem commits (git bisect)• Tools for restructuring branches w/ specific commits

Copyright © C. Aniszczyk, S. Lay, B. Muskalla, K. Sawicki, M. Sohn, S. Zivkov

Page 4: Eclipse Hacker's Guide to the Git Universe

Git at Eclipse

JGit is a lightweight Java library implementing Git • http://www.eclipse.org/jgit/

EGit is an Eclipse Team provider for Git based on JGit• http://www.eclipse.org/egit/

Gerrit Code Review is a Git server based on JGit adding permission control and review workflow• http://code.google.com/p/gerrit• Denis is on the way to setup Gerrit@Eclipse :-)

Copyright © C. Aniszczyk, S. Lay, B. Muskalla, K. Sawicki, M. Sohn, S. Zivkov

Page 5: Eclipse Hacker's Guide to the Git Universe

Git at Eclipse

Eclipse is moving to GitCVS has been deprecated and will be retired 2012-12-21

project / code repository break down as of 2011-10-31

http://eclipse.org/projects/scmcountdown.php

Copyright © C. Aniszczyk, S. Lay, B. Muskalla, K. Sawicki, M. Sohn, S. Zivkov

Page 6: Eclipse Hacker's Guide to the Git Universe

Modern Code Review – What is it ?• When one developer writes code, another developer

is asked to review that code

• A careful line-by-line critique

• Happens in a non-threatening context

• Goal is cooperation, not fault-finding

• Integral part of coding process

• Otherwise this will happen:• Debugging someone else's broken code• – Involuntary code review: Not so good; emotions may flare

Guido van Rossum [1]

[1] http://code.google.com/p/rietveld/downloads/detail?name=Mondrian2006.pdf

Copyright © C. Aniszczyk, S. Lay, B. Muskalla, K. Sawicki, M. Sohn, S. Zivkov

Page 7: Eclipse Hacker's Guide to the Git Universe

Code Review – Benefits

• Four eyes catch more bugso Catch bugs early to save hours of debugging

• Mentoring of new developers / contributorso Learn from mistakes without breaking stuff

• Establish trust relationships o Prepare for more delegation

• Good alternative to pair programmingo asynchronous and across locations

• Coding standardso Keep overall readability & code quality high

Guido van Rossum [1]

[1] http://code.google.com/p/rietveld/downloads/detail?name=Mondrian2006.pdf

Copyright © C. Aniszczyk, S. Lay, B. Muskalla, K. Sawicki, M. Sohn, S. Zivkov

Page 8: Eclipse Hacker's Guide to the Git Universe

Developer PC

Gerrit

git gitgitgit

Developer PC

gitgit

Hudson

- clone repository - fetch / push changes

- verify proposed changes- continuous integration builds

Copyright © C. Aniszczyk, S. Lay, B. Muskalla, K. Sawicki, M. Sohn, S. Zivkov

Page 9: Eclipse Hacker's Guide to the Git Universe

Developer PC

gitgit

Gerrit

git gitgitgit

push improved change 10

Developer PC

gitgit

fetch change 23 to try it

master

change 12

change 10

change 23

submit accepted change 12

fetch master to get updates

Copyright © C. Aniszczyk, S. Lay, B. Muskalla, K. Sawicki, M. Sohn, S. Zivkov

Page 10: Eclipse Hacker's Guide to the Git Universe

Exercises 1 Setup and Cloning Sample Repository 

 

Copyright © C. Aniszczyk, S. Lay, B. Muskalla, K. Sawicki, M. Sohn, S. Zivkov

Page 11: Eclipse Hacker's Guide to the Git Universe

Local Development with EGit

Copyright © C. Aniszczyk, S. Lay, B. Muskalla, K. Sawicki, M. Sohn, S. Zivkov

Page 12: Eclipse Hacker's Guide to the Git Universe

Exercises: Local Development with EGit 2 Develop a feature/bug fix 3 Work on branches in parallel 4 Merge, Rebase, Resolve Conflicts 5 Change a series of commits    

Copyright © C. Aniszczyk, S. Lay, B. Muskalla, K. Sawicki, M. Sohn, S. Zivkov

Page 13: Eclipse Hacker's Guide to the Git Universe

Gerrit Code Review

Copyright © C. Aniszczyk, S. Lay, B. Muskalla, K. Sawicki, M. Sohn, S. Zivkov

Page 14: Eclipse Hacker's Guide to the Git Universe

Gerrit Architecture

Gerrit = Git server             + Access Permissions             + Web UI

• Git based code review system• Hosts many Git repositories• Speaks Git protocol

o no Gerrit client installation required• Provides per-project Access Permissions• Web interface for Code Review

o implemented using GWT

Copyright © C. Aniszczyk, S. Lay, B. Muskalla, K. Sawicki, M. Sohn, S. Zivkov

Page 15: Eclipse Hacker's Guide to the Git Universe

When does Code Review Happen?

• Code Review happens before changes reach the code base

• Buggy changes discovered and fixed before the change gets merged

• Only completed changes reach the project historyo reviewers reject unfinished changes

• Only well described changes reach the code baseo commit message is also subject of the

review

• Project history clean and usableCopyright © C. Aniszczyk, S. Lay, B. Muskalla, K. Sawicki, M. Sohn, S. Zivkov

Page 16: Eclipse Hacker's Guide to the Git Universe

Integration with EGit

• Since Gerrit is a Git (server) any Git implementation can work with Gerrit

• However, EGit provides some extra features to make work with Gerrit more comfortableo fetching a change from Gerrit based on its IDo automatic "push to Gerrit" configuration when

cloning a Git repo from Gerrit

• Mylyn Reviews has a Gerrit connector (see next part)

Copyright © C. Aniszczyk, S. Lay, B. Muskalla, K. Sawicki, M. Sohn, S. Zivkov

Page 17: Eclipse Hacker's Guide to the Git Universe

Exercises: Gerrit Code Review 6.1 Push a Change to Gerrit 6.2 Review a Change 6.3 Improve a Change 6.4 Submit a Change to the Codebase    

Copyright © C. Aniszczyk, S. Lay, B. Muskalla, K. Sawicki, M. Sohn, S. Zivkov

Page 18: Eclipse Hacker's Guide to the Git Universe

Mylyn Integration

Copyright © C. Aniszczyk, S. Lay, B. Muskalla, K. Sawicki, M. Sohn, S. Zivkov

Page 19: Eclipse Hacker's Guide to the Git Universe

Copyright © C. Aniszczyk, S. Lay, B. Muskalla, K. Sawicki, M. Sohn, S. Zivkov

90% Irrelevant

Page 20: Eclipse Hacker's Guide to the Git Universe

Copyright © C. Aniszczyk, S. Lay, B. Muskalla, K. Sawicki, M. Sohn, S. Zivkov

Task-focused IDE

Page 21: Eclipse Hacker's Guide to the Git Universe

< Demo >

Copyright © C. Aniszczyk, S. Lay, B. Muskalla, K. Sawicki, M. Sohn, S. Zivkov

Page 22: Eclipse Hacker's Guide to the Git Universe

Exercises: Mylyn Integration 7.1 Mylyn / EGit Integration 7.2 Use Gerrit from within the IDE  

Copyright © C. Aniszczyk, S. Lay, B. Muskalla, K. Sawicki, M. Sohn, S. Zivkov

Page 23: Eclipse Hacker's Guide to the Git Universe

GitHub Eclipse Support

Copyright © C. Aniszczyk, S. Lay, B. Muskalla, K. Sawicki, M. Sohn, S. Zivkov

Page 24: Eclipse Hacker's Guide to the Git Universe

GitHub Eclipse Support

• https://github.com/eclipseo 176 mirrored repositories

• Browsing source code• Comparing branches and tags• Activity feeds• Charts & Graphs• Downloading snapshots

Copyright © C. Aniszczyk, S. Lay, B. Muskalla, K. Sawicki, M. Sohn, S. Zivkov

Page 25: Eclipse Hacker's Guide to the Git Universe

GitHub Eclipse Support

Page 26: Eclipse Hacker's Guide to the Git Universe

GitHub EGit Integration

• GitHub Mylyn Connectoro Issueso Gistso Pull Requestso Import Wizard

• GitHub Java APIo Maven pluginso Reportingo Automating tasks

Copyright © C. Aniszczyk, S. Lay, B. Muskalla, K. Sawicki, M. Sohn, S. Zivkov

Page 27: Eclipse Hacker's Guide to the Git Universe

Exercises: GitHub/Eclipse Integration 8 Setup Share on GitHub  

Copyright © C. Aniszczyk, S. Lay, B. Muskalla, K. Sawicki, M. Sohn, S. Zivkov

Page 28: Eclipse Hacker's Guide to the Git Universe

Q&A

Copyright © C. Aniszczyk, S. Lay, B. Muskalla, K. Sawicki, M. Sohn, S. Zivkov