Ce diaporama a bien été signalé.
Nous utilisons votre profil LinkedIn et vos données d’activité pour vous proposer des publicités personnalisées et pertinentes. Vous pouvez changer vos préférences de publicités à tout moment.

Git like a Pro (How to use it as it was meant to)

2 721 vues

Publié le

By now, I hardly think anybody needs an introduction to Git. It's becoming the de-facto standard for open-source projects, as well as the main source control system for a lot of corporations. However, Git is just one part of it. Combining it with modern hosting platforms like Github, Bitbucket or Visual Studio Online allows some truly fascinating ways of working with lots of people. Pull Requests, GitFlow, MyGet and GitVersion are crucial in a scalable software development organization. In this session I'll share how we've been using Git and these tools for over two years now. I'll explain how these tools helped us. I'll show you some awesome uses of Git that will truly help you in your day-to-day work.

Publié dans : Technologie

Git like a Pro (How to use it as it was meant to)

  1. 1. Knowledge. People. Solutions. Dennis Doomen (@ddoomen) 29-1-2016 Git like a Pro
  2. 2. About Me 2 • 19 years in business • C#/.NET developer with roots in C++ • TDD/BDD, DDD, Event Sourcing, CQRS, OO, Design Patterns, Architecture • Scrum/XP/Kanban, ALM • Occasional Speaker • www.csharpcodingguidelines.com • www.fluentassertions.com • www.continuousimprover.com
  3. 3. 29-1-2016 Development Workflows
  4. 4. Git in a Nutshell 4 EBA C D F G feature master1.3.0 Commit Tag Branch Head Other Parent Parent d683499b006c422974886 04b352f206a4c0e1382 d683499b
  5. 5. 29-1-2016 Shared Master Branches Commits Tags GitHub Bitbucket, Visual Studio Online, TFS Branches Commits Tags Remotes John’s Clone Mike’s Clone Branches Commits Tags Remotes Branches Commits Tags Remotes Jane’s Clone Local Machine git push master git pull master git push master git clone git pull master git push master git pull master
  6. 6. 29-1-2016 Shared Feature Branch Branches Commits Tags Branches Commits Tags Remotes John’s Clone Mike’s Clone Branches Commits Tags Remotes Branches Commits Tags Remotes Jane’s Clone git push feat1 git push mastergit pull feat1 git push feat1 git pull feat1 git checkout master git merge feat1git checkout –b feat1 GitHub Bitbucket, Visual Studio Online, TFS Local Machine
  7. 7. 29-1-2016 Shared Feature Branch with Pull Request Branches Commits Tags Branches Commits Tags Remotes John’s Clone Mike’s Clone Branches Commits Tags Remotes Branches Commits Tags Remotes Jane’s Clone git push feat1 git push feat1git pull feat1 git push feat1 git pull feat1 git checkout –b feat1 GitHub Bitbucket, Visual Studio Online, TFS Local Machine feat1 -> master
  8. 8. 29-1-2016 Shared Fork with Pull Request Branches Commits Tags Branches Commits Tags Remotes John’s Clone Mike’s Clone Branches Commits Tags Remotes Branches Commits Tags Remotes Jane’s Clone git push john feat1 git push john feat1 fork git push john feat1 git pull john feat1 git checkout –b feat1 GitHub Bitbucket, Visual Studio Online, TFS Local Machine john/feat1 -> main/master Branches Commits Tags John’s Fork git pull john feat1
  9. 9. 29-1-2016 Tools
  10. 10. Popular Tools • Atlassian SourceTree • Git Extensions • Github Desktop • SmartGit • Visual Studio 2013/2015 • PowerShell + PoshGit + Jump-Location • Bash • GitKraken 10
  11. 11. 29-1-2016 Aliasing like a Pro
  12. 12. Aliasing like a Pro • git cob • git cm • git wipe • git amend • git bclean, git bdone • git save, git undo • git up, git fa • Stored in – %userprofile%.gitconfig – .gitconfig 12
  13. 13. 29-1-2016 Release Strategies
  14. 14. Semantic Versioning 14 2.3.1 Breaking Changes Backwards Compatible Changes Patches
  15. 15. GitHubFlow 15 Source: https://blog.oio.de/2014/09/22/git-workflows-teil-2-workflows-meistern/
  16. 16. GitFlow 16
  17. 17. 29-1-2016 GitVersion
  18. 18. 29-1-2016 Merging Strategies
  19. 19. Simple Merge 19 EBA C D F G feature master git merge feature Merge commit
  20. 20. Fast-Forward Merge 20 BA C D Efeature master git merge feature
  21. 21. Squashing Merge 21 EBA C D F G feature master git merge feature --squash Merge commit
  22. 22. Cherry-Pick 22 EBA C D F D’ feature master git cherry-pick D commit
  23. 23. Rebase Merge 23 EBA C D Efeature master C’ D’ E’ git rebase master feature git merge feature
  24. 24. Discard Merge 24 EBA C D F G feature master git merge feature –-strategy ours empty commit (!)
  25. 25. 29-1-2016 The Beauty of a Clean History
  26. 26. Keep your history clean Source: http://www.tugberkugurlu.com/tags/git • Traceability • Reviewability • Historical drilling • Rebasing • Reverting • git bisect 26
  27. 27. 29-1-2016 Divide and Conquer your Branches
  28. 28. Move local changes to new branch 28 ?BA feature master git checkout –b feature Uncommitted changes ?
  29. 29. Move committed changes to new branch 29 CBA feature master git checkout –b feature git reset B --hard
  30. 30. 29-1-2016 Extract committed changes CBA Bfeature master C’ git checkout B –b feature git rebase A -i
  31. 31. 29-1-2016 Extract committed changes (alternative) FBA feature master C’ git checkout A –b feature C D E git cherry-pick C F’D’ E’ git rebase B -i
  32. 32. 29-1-2016 Not for the faint of heart
  33. 33. 29-1-2016 Submodules Branches Commits Tags Remotes Branches Commits Tags Remotes .gitmodules GitHub Bitbucket, Visual Studio Online, TFS Local Machine Branches Commits Tags Branches Commits Tags .subrepo git submodule add repo-url git clone –recursive sub-repo-url git config submodule.subrepo.url alternative-url git submodule update --remote [submodule “subrepo"] path = .subrepo url = https://github.com/subrepo branch = feature git config submodule.DbConnector.url PRIVATE_URL
  34. 34. Advanced • git commit –-all –amend • git push --force • git reflog • .gitignore/.gitattributes tuning • git bisect • git worktree add -b hot-fix ../hotfix master • git clone –-depth 0 • git rerere (“reuse recording resolution”) • git subtree • git notes (supported by Github) • git rebase --autostash 34
  35. 35. 29-1-2016 How we like to work
  36. 36. 29-1-2016 How I like to work Central Repo John’s fork Dean’s fork master master shared Dean’s changes Mike’s changes Task1 git rebase -i Mike’s fork Task2 git rebase -i Pull Request Pull Request Task3 Pull Request Pull Request John’s changes
  37. 37. 29-1-2016
  38. 38. Resources • A scalable software development organization by using Git http://www.continuousimprover.com/2015/03/a-scalable-software-development.html • Why should abandon TFS Source Control and adopt Git http://www.continuousimprover.com/2015/06/why-you-should-abandon-tfs-source.html • Semantic Merge https://www.semanticmerge.com/ • Git Aliases http://haacked.com/archive/2014/07/28/github-flow-aliases/ • Awesome Git tutorials http://pcottle.github.io/learnGitBranching/ • GitVersion https://github.com/GitTools/GitVersion • Semantic Versioning http://semver.org/ • GitFlow vs GitHubFlow http://gitversion.readthedocs.org/en/latest/git-branching-strategies/ • Pro Git (the book) https://git-scm.com/book/en/v2 38
  39. 39. How to find me? 39 • @ddoomen • dennis.doomen@avivasolutions.nl • www.continuousimprover.com • www.csharpcodingguidelines.com • github.com/dennisdoomen • www.fluentassertions.com
  40. 40. 29-1-2016 Thanks!
  41. 41. Knowledge. People. Solutions.

×