git and eclipse - mannheim java user group - 2010-09-02
DESCRIPTION
EGit & Gerrit Presentation held at Mannheim Java User Group on 2010-09-02TRANSCRIPT
Git and Eclipsehttp://eclipse.org/egit
Stefan Lay (SAP)[email protected]
Matthias Sohn (SAP)[email protected]
Twitter: @stefanlay, @masohn
+ =
Git at Eclipse | © 2010 by S. Lay and M. Sohn
Git at Eclipse
Git is a Distributed Version Control System
EGit is an Eclipse Team provider for Git http://www.eclipse.org/egit/
JGit is a lightweight Java library implementing Git http://www.eclipse.org/jgit/
The goal is to build an Eclipse community around Git. EGit is still beta and we want to establish a feedback loop to improve the tooling.
Git at Eclipse | © 2010 by S. Lay and M. Sohn
Gerrit Code Review
Gerrit is a Code Review system based on JGit http://code.google.com/p/gerrit/
Also serves as a central git server adding access control and workflow
Used by Android, JGit/Egit, …
Git at Eclipse | © 2010 by S. Lay and M. Sohn
History JGit/EGit2005 Linus Torvalds starts Git
2006 Shawn Pearce starts JGit
2009 Eclipse decides on Git JGit/EGit move to eclipse.org SAP joins
3/2010 Released 0.7 (first release at Eclipse) Diff/Merge Algorithms, Automatic IP Logs
6/2010 Released 0.8 (Helios) Usability Improvements, Git Repositories View, Tagging
9/2010 Planned 0.9 (Helios SR1) Merge, Synchronize View, .gitignore
Git vs. CVS/SVN
• Distributedo Each user has full history
o Ability to work off-line
o Fast
o Rebase patches easily
o Forks happen, deal with it
o Powerful merging allows to use lots of branches
• Centralizedo --
o --
o Slow
o Patches go stale
o Forks are painful
o Merging is painful
Git at Eclipse | © 2010 by S. Lay and M. Sohn
Git in OS and inside a company
• Git was invented for OpenSource project: Linux kernel developmento Distributed versioning has benefits for contributors in
OS development model
• Committer / contributor model can also be beneficial inside a company
• Git and Gerrit enable code review workflow
Git at Eclipse | © 2010 by S. Lay and M. Sohn
Code Review – Why ?
Good means to improve quality
Cooperate to make changes perfect
Helps learning and avoiding silos
The way to get contributions from new contributors integrated without risk
Helps to discuss drafts on source code level beforethey reach master
Git at Eclipse | © 2010 by S. Lay and M. Sohn
Code Review - Workflow
• Review every change• Authors can explicitly invite
reviewers• Look at the change• Comment on how to improve it• Discuss in context of the change• Complex changes reviewed
by many• Discussion leads to new
improved change (sometimes we have 20 versions until submit)
Git at Eclipse | © 2010 by S. Lay and M. Sohn
Code Review - Experience
• Review takes time (1 day … months) o Implies parallel workflow o Every team member should do reviews regularlyo Authors have to wait for the review to happeno Git & Gerrit help a lot here
o Small changes are much easier to reviewo A change should logically do one thing (not many)o Split big changes into series of digestible
changes (patch series)
o Commit message should explain Why o The What should be obvious from the code change
Git at Eclipse | © 2010 by S. Lay and M. Sohn
Code Review – Lifecycle of a Change
Git at Eclipse | © 2010 by S. Lay and M. Sohn
aa
mastermaster
topictopic
11
• create local topic branch• commit change• push it for review• review• automated verification
Code Review – Lifecycle of a Change
Git at Eclipse | © 2010 by S. Lay and M. Sohn
cc
bb
aa11
22
mastermastertopictopic
33
aa
mastermaster
topictopic
11
• create local topic branch• commit change• push it for review• review• automated verification
• refine based on review• push new patchsets until review votes ok
Code Review – Lifecycle of a Change
Git at Eclipse | © 2010 by S. Lay and M. Sohn
cc
bb
aa11
22
mastermastertopictopic
33
aa
mastermaster
topictopic
11
• create local topic branch• commit change• push it for review• review• automated verification
• refine based on review• push new patchsets until review votes ok
cc
bb
aa11
22
mastermaster
topictopic
33
dd
• Submit may lead to server-side merge• or merge / rebase before push
No Free Lunch -- DEMO
The best way to learn Git is to use Git
Git at Eclipse | © 2010 by S. Lay and M. Sohn
Conclusion
DVCS like Git are powerful
Git supports convenient branching and merging Git is very fast and scales wellGerrit enables a nice code review workflow
Git is the future SCM of Eclipse
Git at Eclipse | © 2010 by S. Lay and M. Sohn
Git at Eclipse
EGit/JGit developed at http://egit.eclipse.org
http://git.eclipse.org/ hosts live Eclipse Git reposVirgo, Mylyn Review, ScalaModules, SWTBot …
http://dev.eclipse.org/git/index.html git mirrors for CVSRead-only copies kept up-to-dateCan clone with git:// or http://
Git at Eclipse | © 2010 by S. Lay and M. Sohn
Resources
Ask questions on the EGit forum or egit-dev/jgit-dev lists
http://git-scm.com/documentation is your friend
If you want comedy, watch Linus' talk at Googlehttp://www.youtube.com/watch?v=4XpnKHJAok8
Read the Pro Git book - http://progit.org/book/
Git at Eclipse | © 2010 by S. Lay and M. Sohn
Features EGit 0.9
git-addgit-add git-format-patchgit-format-patch git-shortloggit-shortlog git-relinkgit-relink git-rev-parsegit-rev-parse
git-amgit-am git-gcgit-gc git-showgit-show git-remotegit-remote git-show-branchgit-show-branch
git-archivegit-archive git-grepgit-grep git-stashgit-stash git-repackgit-repack git-verify-taggit-verify-tag
git-bisectgit-bisect git-initgit-init git-statusgit-status git-replacegit-replace git-whatchangedgit-whatchanged
git-branchgit-branch git-loggit-log git-submodulegit-submodule git-annotategit-annotate
git-bundlegit-bundle * git-merge* git-merge * git-tag* git-tag git-blame git-blame
git-checkoutgit-checkout git-mvgit-mv git-configgit-config git-cherrygit-cherry .gitignore.gitignore
git-cherry-pick git-cherry-pick git-notesgit-notes git-fast-exportgit-fast-export git-count-objectsgit-count-objects git daemongit daemon
git-cleangit-clean * git-pull* git-pull git-fast-importgit-fast-import git-difftoolgit-difftool * HTTP support* HTTP support
git-clonegit-clone git-pushgit-push git-filter-branchgit-filter-branch git-fsckgit-fsck * Mylyn integration* Mylyn integration
git-commitgit-commit * git-rebase* git-rebase git-mergetoolgit-mergetool git-get-tar-commit-idgit-get-tar-commit-id * Staging View* Staging View
git-describegit-describe git-resetgit-reset git-pack-refsgit-pack-refs git-helpgit-help * Synchronize View* Synchronize View
git-diffgit-diff git-revertgit-revert git-prunegit-prune git-merge-treegit-merge-tree History ViewHistory View
git-fetchgit-fetch git-rmgit-rm git-refloggit-reflog git-rereregit-rerere Repositories ViewRepositories View
* planned for next release, supported, partial, missing, irrelevant for EGit