git workflows
play

Git Workflows Sylvain Bouveret, Grgory Mouni, Matthieu Moy 2017 - PowerPoint PPT Presentation

Git Workflows Sylvain Bouveret, Grgory Mouni, Matthieu Moy 2017 [first].[last]@imag.fr http://recherche.noiraudes.net/resources/git/git-workflow-slides.pdf Git Workflow 1 / 16 Goals of the presentation Global history: multiple


  1. Git Workflows Sylvain Bouveret, Grégory Mounié, Matthieu Moy 2017 [first].[last]@imag.fr http://recherche.noiraudes.net/resources/git/git-workflow-slides.pdf Git Workflow 1 / 16

  2. Goals of the presentation • Global history: multiple workflow • Global history: branching, rebasing, stashing Git Workflow 2 / 16

  3. Workflows

  4. Branches Branching exists in most VCS. The goal is to keep track separately of the various parallel works done on an on-going software development. This is Git killing feature: Git branch management (and merge) is lightweight and efficient. Thus it is quite easy to split the work among the developpers and still let them work easily together toward the common goal. But it is not a magic bullet: the splitting of the work should be handle with care. Git Workflow 3 / 16

  5. Example of bad splitting: per developer branches Pro • simple to define and set-up ✓ Cons • missing information: to find something, you need to know who did it ✗ • redundant information: committer and branch name are strongly related ✗ • confusing and error prone code sharing, blending new feature development and bug correction ✗ • developers use old version of common code ✗ • As it does not enforce convergence of code ⇒ the multiple incompatible development are increasingly difficult to merge ✗ Git Workflow 4 / 16

  6. Better splitting: per topic branches • master branch contain release versions • develop branch contain ongoing development • release branch to prepare new release in master • hotfix branch for bug correction of release version • feature branch to develop new features [Vincent Driessen, http://nvie.com/posts/ a-successful-git-branching-model/ ] Git Workflow 5 / 16

  7. Code sharing models Distributed VCS such as Git are ... distributed. The code is thus modified at several places at the same time. There are many different ways to share the code modifications between repositories. Git Workflow 6 / 16

  8. Code sharing: centralized workflow central Similar to SVN way of repository life, just fully operational with branches, merge and off-line work. Quite good for small teams. developer developer developer repository repository repository Git Workflow 7 / 16

  9. Code sharing: centralized workflow central Similar to SVN way of repository life, just fully operational with branches, merge and off-line work. Quite good for small teams. developer developer developer repository repository repository Additional transfers using git are easy and safe ! The tricky part The most important point is to use git for transfer patches. Any transfer outside git can not be taken into account in futur merge. Git Workflow 7 / 16

  10. Centralized workflow 1 ❞♦ { ✇❤✐❧❡ ( nothing_interesting ()) 2 3 work (); 4 ✇❤✐❧❡ ( uncommited_changes ()) { 5 ✇❤✐❧❡ (! happy) { // git diff --staged ? 6 ✇❤✐❧❡ (! enough) git add -p; ✇❤✐❧❡ (too_much) git reset -p; 7 8 } 9 git commit; // no -a 10 ✐❢ ( nothing_interesting ()) 11 git stash; } 12 13 ✇❤✐❧❡ (! happy) 14 git rebase -i; 15 } ✇❤✐❧❡ (! done); 16 git push; // send code to central repository Git Workflow 8 / 16

  11. Code sharing: Github workflow • Released and official developer blessed branches are stored in the public repository blessed repository. repository • Contributors forks and works pull privately • Contributors publish their developer integration work and ask for merge private repository repository • Integrators merges then publish the contributions Git Workflow 9 / 16

  12. Code sharing: Github workflow • Released and official developer blessed branches are stored in the public repository blessed repository. repository • Contributors forks and works push privately • Contributors publish their developer integration work and ask for merge private repository repository • Integrators merges then publish the contributions Git Workflow 9 / 16

  13. Code sharing: Github workflow • Released and official developer blessed branches are stored in the public repository blessed repository. repository pull • Contributors forks and works privately • Contributors publish their developer integration work and ask for merge private repository repository • Integrators merges then publish the contributions Git Workflow 9 / 16

  14. Code sharing: Github workflow • Released and official developer blessed branches are stored in the public repository blessed repository. repository • Contributors forks and works push privately • Contributors publish their developer integration work and ask for merge private repository repository • Integrators merges then publish the contributions Git Workflow 9 / 16

  15. Code sharing: Github workflow • Released and official developer blessed branches are stored in the public repository blessed repository. repository pull • Contributors forks and works pull push push privately • Contributors publish their developer integration work and ask for merge private repository repository • Integrators merges then publish the contributions Public mailing list as public repository Git patches can be send by email ( git format-patch -1 ), published in mailing-list (eg. bug-gnu-emacs@gnu.org), then integrated ( git am ) Git Workflow 9 / 16

  16. Triangular Workflow with pull-requests • Developers pull from upstream, and push to a “to be merged” location • Someone else reviews the code and merges it upstream merge merge B’s public repo Upstream A’s public repo clone, pull clone, pull push push B’s private repo A’s private repo Git Workflow 10 / 16

  17. Pull-requests in Practice Contributor create a branch, commit, push Contributor click “Create pull request” (GitHub, GitLab, BitBucket, ...), or git request-pull Maintainer receives an email Maintainer review, comment, ask changes Maintainer merge the pull-request The code review is the major point for code quality insurance ! Git Workflow 11 / 16

  18. Code Review • What we’d like: 1. A writes code, commits, pushes 2. B does a review 3. B merges to upstream • What usually happens: 1. A writes code, commits, pushes 2. B does a review 3. B requests some changes 4. ... then ? Git Workflow 12 / 16

  19. Iterating Code Reviews • At least 2 ways to deal with changes between reviews: 1. Add more commits to the pull request and push them on top 2. Rewrite commits ( rebase -i , . . . ) and overwrite the old pull request • The resulting history is clean • Much easier for reviewers joining the review effort at iteration 2 • e.g. On Git’s mailing-list, 10 iterations is not uncommon. Git Workflow 13 / 16

  20. Code sharing: Linux kernel workflow dictator public • Code review and basic repository repository filtering of contributions is done by the lieutenants lieutenant • Final decision is done by the public benevolent dictator repository • Lieutenant repositories are the testbeds of new ideas developer developer public public that mature in it before repository repository upstream submission Git Workflow 14 / 16

  21. Code sharing: remote management Remote allows to work with several sources and sink $ git remote add lieutenant git://.../public.git $ git remote origin lieutenant $ git fetch lieutenant ... $ git branch -r origin/HEAD -> origin/master origin/master lieutenant/master $ git checkout -b lieutenant lieutenant/master Git Workflow 15 / 16

  22. Branches and tags in practice

  23. Branches and Tags in Practice • Create a local branch and check it out: git checkout -b branch-name • Switch to a branch: git checkout branch-name • List local branches: git branch • List all branches (including remote-tracking): git branch -a • Create a tag: git tag tag-name Git Workflow 16 / 16

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend