Git and Git Workflow Models as Catalysts of Software Development

  • View
    9

  • Download
    2

Embed Size (px)

DESCRIPTION

This is the slides of my latest talk in DevFest Istanbul 2013 which is organized by Google Developers Group Istanbul. The content mainly has 3 sections. Git branching model in theory, creating a feature by git commands and git best practices.

Text of Git and Git Workflow Models as Catalysts of Software Development

  • GIT & GIT workflow MODELsAS CATALYSTS OF SOFTWARE DEVELOPMENT@lemiorhanLem Orhan ERGN lemiorhanergin.com@lemiorhan

Lem Orhan Ergn CSM, PSM12013Principal Software Engineer at Sony2001has worked in Tsside, BYM, GittiGidiyor/eBay and Sony as lead developer, technical leader, technical coordinator and scrum master2009 2 2005using Git, but not an expertagile 0.5Mexperienced in agile transformation and building agile culture in teams & organisationsorganisational level SVN to GIT migration projects experienced so far doing code reviews as a daily habittotal number of views of his presentations I love git I love git becauseI used SVN for a while Local branching is cheap Everything is local Distributed Ruby on Rails with full history and branches weight 13Mb. Small and efcient It weights 115Mb in SVN Any workow Each object is compressed by zlib and transferred over wire Lightening Fast one by one Huge community More than 3M people More than 5M repositories GitHub Thanks God! Raised $100 million on July'12 git data model ishotIt is a directed acyclic graph Objects (blob, tree, commit, tag) are immutable References (branch, remote) always change Stop comparing SVN with GIT It is not a magical version of SVN. Try to understand what it's actually doing. It's a stupid content tracker. It tracks les and folders.I really really designed it coming at the problem from the viewpoint of a le system person, I actually have absolutely zero interest in creating a traditional SCM system. LINUS TOVALDS gitchanged the way we think ofmerging branching workflows git is a tool for designing vcs workflows main branches supporting branches Feature development release development hot fixes in productiongit workflow model main branchesmain branches are permanent branches which are created at the very beginning and never delete d! main branchesOPTONAL developmentIt reects the latest delivered development changes for the next releaseAutomatic nightly buildstest & QASTAGING & UATMASTER Production main branchesOPTONAL developmenttest & QAIt reects the code which is deployed to test/qa environment for testingAutomatic nightly buildsAutomatically deployed to test/qa servers every nightSTAGING & UATMASTER Production main branchesOPTONAL developmenttest & QASTAGING & UATIt reects the code which is deployed to staging/uat environment for testingAutomatic nightly buildsAutomatically deployed to staging servers every night Automatically deployed to test/qa servers every nightMASTER Production main branchesOPTONAL developmenttest & QASTAGING & UATMASTER ProductionIt reects the code which is deployed to productionAutomatic nightly buildsAutomatically deployed to staging servers every night Automatically deployed to test/qa servers every nightAutomatically deployed to production servers on demand supporting branchesfeature branches HOTFIX branches release branches These have limited life time and will be removed eventually supporting branchesfeature branches HOTFIX branches release branches These have specific purposeand strict rules for originating and target branches Feature developmentAll feature branches should be created fromThe development branch the next r eleas e branch Feature developmenttake a new feature branchregardless of the feature size you ca comm n fix v in dev on issue ery mino elopm s direc r like f ent b tly ixing ranch typos , Feature developmentNeFeature 1Feature 22Feature 2 is completed and ready for the next releaseFeature 3xtdevelopment Rel ea se NeFeature developmentFeature 1Feature 1 is being developedFeature 22 1Feature 3xtdevelopment Rel ea se Feature developmentNeFeature 1Feature 2Feature 3xtdevelopment Rel ea se2 1 DFeature 2 is completed and merged back to master NeFeature developmentFeature 1Feature 1 gets the commits in Feature 2Feature 2Feature 3development Rel ea se2 1 D 1xt NeFeature developmentFeature 1Pulls all the commits from other features and resolve conictsFeature 2Feature 3development Rel ea se2 1 D 1 1xtD Feature developmentNeFeature 1Feature 2Feature 3xtdevelopment Rel ea se2 1 D 1D1 3Feature 3 is created from development. It has commits of Feature 2 Feature developmentNeFeature 1Feature 2Feature 3xtdevelopment Rel ea se2 1 D 1D1 3 DFeature 1 is completed and merged back to master Feature developmentNeFeature 1Feature 2Feature 3development Rel ea se2 1 D 1D1 3 D3Feature 3 gets the commits of Feature 1xt Feature developmentNeFeature 1Feature 2Feature 3development Rel ea se2 1 D 1D1 3 D3 3Feature 3 pull updates frequentlyxtD Feature developmentNeFeature 1Feature 2Feature 3xtdevelopment Rel ea se2 1 D 1D1 3 D3 3D DTypo is xed directly in development branch Feature developmentNeFeature 1Feature 2Feature 3development Rel ea se2 1 D 1D1 3 D3Feature 3 pulls commit about xing the typo3 3xtD D Feature developmentNeFeature 1Feature 2Feature 3xtdevelopment Rel ea se2 1 D 1D1 3 D3 3D D3 DFeature 3 is completed and merged back to master. It has commits of all 3 features now. release developmentRelease branch is created whenall features are ready for the next release some featu times w re fre e call eze it as release developmentRelease branch is deleted whenthe release completes we w code, ill tag t branc no need he releas to ke ed h.. ep th e release developmentelNt exs eaeR developmentF D F DCompleted features are merged with developmentreleaseMASTER Production release developmentelNt exs eaeR developmentF D F DDAll features are ready for the next releasereleaseMASTER Production release developmentelNt exs eaeR developmentreleaseMASTER ProductionF D F DStart a release branch when features are freezedD R release developmentelNt exs eaeR developmentreleaseMASTER ProductionF D F DD ROnly xes are allowed R D RBug xes are continuously merged back to development brachD release developmentelNt exs eaeR developmentreleaseMASTER ProductionF D F DD R R D R D RRelease is ready now release developmentelNt exs eaeR developmentreleaseF D F DD R R D RLatest xes are merged back to development branchD R DMASTER Production release developmentelNt exs eaeR developmentreleaseMASTER ProductionF D F DD R R D R DMerge release branch with master branch and get a new tagR D M hot fixes in productionFix branches are required because every fix should bewell tested and verifiedit me to rol ans, you done i lback w may nee n the hat yo d fix uve hot fixes in productionelNt exs eaeR developmentHot-FIXMASTER ProductionHot x is required! A new branch is created from production branch M hot fixes in productionelNt exs eaeR developmentHot-FIXMASTER ProductionMFix is developed, tested and veried. Ready to go. H hot fixes in productionelNt exs eaeR developmentHot-FIXMASTER ProductionMHDHot xes are merged back to development branch hot fixes in productionelNt exs eaeR developmentHot-FIXMASTER ProductionMHHot x is merged with production branch and production branch is taggedD M ALL FLOWS IN THE MODELThis graphic is taken from Vincent Driessens article called a successful git branching model feature development 1creatE permanent branches If these does not existgit:(master) git checkout -b development Switched to a new branch 'development'git:(development) git push origin development Total 0 (delta 0), reused 0 (delta 0) To UberProject.git * [new branch] development -> developmentgit:(development) git branch -a * development master remotes/origin/development remotes/origin/masterit cre branc ates de v pushe h from m elopme s to r aste nt emot r and e 2Pull to update local development branch be sure you run tests directly afterwardsgit:(master) git fetch origin From UberProject * [new branch] development -> origin/developmentgit:(master) git checkout development Branch development set up to track remote branch development from origin. Switched to a new branch development'git:(development) git pull remote: Counting objects: 19, done. remote: Compressing objects: 100% (8/8), done. remote: Total 17 (delta 2), reused 0 (delta 0) Unpacking objects: 100% (17/17), done. From UberProject 3eb8b34..c827c84 development -> origin/development Updating 3eb8b34..c827c84 Fast-forward grails-app/controllers/org/example/BookController.groovy | 6 ++++++ grails-app/domain/org/example/Book.groovy | 7 +++++++ test/unit/org/example/BookControllerTests.groovy | 17 +++++++++++++++++ test/unit/org/example/BookTests.groovy | 17 +++++++++++++++++ 4 les changed, 47 insertions(+) create mode 100644 grails-app/controllers/org/example/BookController.groovy create mode 100644 grails-app/domain/org/example/Book.groovy create mode 100644 test/unit/org/example/BookControllerTests.groovy create mode 100644 test/unit/org/example/BookTests.groovy 3create a feature branch from developmentwith a name having story id and descriptive titlegit:(development) git checkout -b feature-1185-add-commenting Switched to a new branch 'feature-1185-add-commenting'git:(feature-1185-add-commenting)the t hints itle shou about ld giv what e s init 4work in your feature branch commit early and oftenBe careful! push early it does not mean and oftengit:(feature-1185-add-commenting) vi web-app/WEB-INF/applicationContext.xml git:(feature-1185-add-commenting) git add . git:(feature-1185-add-commenting) git commit -m "added comment for applicationContext.xml" [feature-1185-add-commenting b6f68cc] added comment for applicationContext.xml 1 le changed, 2 insertions(+), 1 deletion(-)!git:(feature-1185-add-commenting) vi web-app/WEB-INF/sitemesh.xml git:(feature-1185-add-commenting) git add . git:(feature-1185-add-commenting) git commit -m "added comment for sitemesh.xml" [feature-1185-add-commenting 0e74f89] added comment for sitemesh.xml 1 le changed, 3 insertions(+), 1 deletion(-)!git:(feature-1185-add-commenting) vi .application.properties git:(feature-1185-add-commenting) git add . git:(feature-1185-add-commenting) git commit -m "increased the application version" [feature-1185-add-commenti