git like a pro (how to use it as it was meant to)
TRANSCRIPT
![Page 1: Git like a Pro (How to use it as it was meant to)](https://reader034.vdocuments.mx/reader034/viewer/2022050613/587ace0a1a28ab760f8b621f/html5/thumbnails/1.jpg)
Knowledge.
People.
Solutions.
Dennis Doomen (@ddoomen)
29-1-2016
Git like a Pro
![Page 2: Git like a Pro (How to use it as it was meant to)](https://reader034.vdocuments.mx/reader034/viewer/2022050613/587ace0a1a28ab760f8b621f/html5/thumbnails/2.jpg)
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
![Page 3: Git like a Pro (How to use it as it was meant to)](https://reader034.vdocuments.mx/reader034/viewer/2022050613/587ace0a1a28ab760f8b621f/html5/thumbnails/3.jpg)
29-1-2016
Development Workflows
![Page 4: Git like a Pro (How to use it as it was meant to)](https://reader034.vdocuments.mx/reader034/viewer/2022050613/587ace0a1a28ab760f8b621f/html5/thumbnails/4.jpg)
Git in a Nutshell
4
EBA
C D F
G
feature
master1.3.0
Commit
TagBranch
Head
Other
Parent
Parent
d683499b006c422974886
04b352f206a4c0e1382d683499b
![Page 5: Git like a Pro (How to use it as it was meant to)](https://reader034.vdocuments.mx/reader034/viewer/2022050613/587ace0a1a28ab760f8b621f/html5/thumbnails/5.jpg)
29-1-2016
Shared MasterBranches
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 mastergit pull master git push master
git clone
git pull master
git push master
git pull master
![Page 6: Git like a Pro (How to use it as it was meant to)](https://reader034.vdocuments.mx/reader034/viewer/2022050613/587ace0a1a28ab760f8b621f/html5/thumbnails/6.jpg)
29-1-2016
Shared Feature BranchBranches
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
![Page 7: Git like a Pro (How to use it as it was meant to)](https://reader034.vdocuments.mx/reader034/viewer/2022050613/587ace0a1a28ab760f8b621f/html5/thumbnails/7.jpg)
29-1-2016
Shared Feature Branch with Pull RequestBranches
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
![Page 8: Git like a Pro (How to use it as it was meant to)](https://reader034.vdocuments.mx/reader034/viewer/2022050613/587ace0a1a28ab760f8b621f/html5/thumbnails/8.jpg)
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
![Page 9: Git like a Pro (How to use it as it was meant to)](https://reader034.vdocuments.mx/reader034/viewer/2022050613/587ace0a1a28ab760f8b621f/html5/thumbnails/9.jpg)
29-1-2016
Tools
![Page 10: Git like a Pro (How to use it as it was meant to)](https://reader034.vdocuments.mx/reader034/viewer/2022050613/587ace0a1a28ab760f8b621f/html5/thumbnails/10.jpg)
Popular Tools
• Atlassian SourceTree
• Git Extensions
• Github Desktop
• SmartGit
• Visual Studio 2013/2015
• PowerShell + PoshGit + Jump-Location
• Bash
• GitKraken
10
![Page 11: Git like a Pro (How to use it as it was meant to)](https://reader034.vdocuments.mx/reader034/viewer/2022050613/587ace0a1a28ab760f8b621f/html5/thumbnails/11.jpg)
29-1-2016
Aliasing like a Pro
![Page 12: Git like a Pro (How to use it as it was meant to)](https://reader034.vdocuments.mx/reader034/viewer/2022050613/587ace0a1a28ab760f8b621f/html5/thumbnails/12.jpg)
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
– .git\config
12
![Page 13: Git like a Pro (How to use it as it was meant to)](https://reader034.vdocuments.mx/reader034/viewer/2022050613/587ace0a1a28ab760f8b621f/html5/thumbnails/13.jpg)
29-1-2016
Release Strategies
![Page 14: Git like a Pro (How to use it as it was meant to)](https://reader034.vdocuments.mx/reader034/viewer/2022050613/587ace0a1a28ab760f8b621f/html5/thumbnails/14.jpg)
Semantic Versioning
14
2.3.1Breaking
Changes
Backwards
Compatible
Changes
Patches
![Page 15: Git like a Pro (How to use it as it was meant to)](https://reader034.vdocuments.mx/reader034/viewer/2022050613/587ace0a1a28ab760f8b621f/html5/thumbnails/15.jpg)
GitHubFlow
15
Source: https://blog.oio.de/2014/09/22/git-workflows-teil-2-workflows-meistern/
![Page 16: Git like a Pro (How to use it as it was meant to)](https://reader034.vdocuments.mx/reader034/viewer/2022050613/587ace0a1a28ab760f8b621f/html5/thumbnails/16.jpg)
GitFlow
16
![Page 17: Git like a Pro (How to use it as it was meant to)](https://reader034.vdocuments.mx/reader034/viewer/2022050613/587ace0a1a28ab760f8b621f/html5/thumbnails/17.jpg)
29-1-2016
GitVersion
![Page 18: Git like a Pro (How to use it as it was meant to)](https://reader034.vdocuments.mx/reader034/viewer/2022050613/587ace0a1a28ab760f8b621f/html5/thumbnails/18.jpg)
29-1-2016
Merging Strategies
![Page 19: Git like a Pro (How to use it as it was meant to)](https://reader034.vdocuments.mx/reader034/viewer/2022050613/587ace0a1a28ab760f8b621f/html5/thumbnails/19.jpg)
Simple Merge
19
EBA
C D F
G
feature
master
git merge feature
Merge commit
![Page 20: Git like a Pro (How to use it as it was meant to)](https://reader034.vdocuments.mx/reader034/viewer/2022050613/587ace0a1a28ab760f8b621f/html5/thumbnails/20.jpg)
Fast-Forward Merge
20
BA
C D Efeature
master
git merge feature
![Page 21: Git like a Pro (How to use it as it was meant to)](https://reader034.vdocuments.mx/reader034/viewer/2022050613/587ace0a1a28ab760f8b621f/html5/thumbnails/21.jpg)
Squashing Merge
21
EBA
C D F
G
feature
master
git merge feature --squash
Merge commit
![Page 22: Git like a Pro (How to use it as it was meant to)](https://reader034.vdocuments.mx/reader034/viewer/2022050613/587ace0a1a28ab760f8b621f/html5/thumbnails/22.jpg)
Cherry-Pick
22
EBA
C D F
D’
feature
master
git cherry-pick D
commit
![Page 23: Git like a Pro (How to use it as it was meant to)](https://reader034.vdocuments.mx/reader034/viewer/2022050613/587ace0a1a28ab760f8b621f/html5/thumbnails/23.jpg)
Rebase Merge
23
EBA
C D Efeature
master
C’ D’ E’
git rebase master
feature
git merge feature
![Page 24: Git like a Pro (How to use it as it was meant to)](https://reader034.vdocuments.mx/reader034/viewer/2022050613/587ace0a1a28ab760f8b621f/html5/thumbnails/24.jpg)
Discard Merge
24
EBA
C D F
G
feature
master
git merge feature –-strategy ours
empty commit (!)
![Page 25: Git like a Pro (How to use it as it was meant to)](https://reader034.vdocuments.mx/reader034/viewer/2022050613/587ace0a1a28ab760f8b621f/html5/thumbnails/25.jpg)
29-1-2016
The Beauty of a Clean History
![Page 26: Git like a Pro (How to use it as it was meant to)](https://reader034.vdocuments.mx/reader034/viewer/2022050613/587ace0a1a28ab760f8b621f/html5/thumbnails/26.jpg)
Keep your history clean
Source: http://www.tugberkugurlu.com/tags/git
• Traceability
• Reviewability
• Historical drilling
• Rebasing
• Reverting
• git bisect
26
![Page 27: Git like a Pro (How to use it as it was meant to)](https://reader034.vdocuments.mx/reader034/viewer/2022050613/587ace0a1a28ab760f8b621f/html5/thumbnails/27.jpg)
29-1-2016
Divide and Conquer your
Branches
![Page 28: Git like a Pro (How to use it as it was meant to)](https://reader034.vdocuments.mx/reader034/viewer/2022050613/587ace0a1a28ab760f8b621f/html5/thumbnails/28.jpg)
Move local changes to new branch
28
?BA
feature
master
git checkout –b feature
Uncommitted
changes
?
![Page 29: Git like a Pro (How to use it as it was meant to)](https://reader034.vdocuments.mx/reader034/viewer/2022050613/587ace0a1a28ab760f8b621f/html5/thumbnails/29.jpg)
Move committed changes to new branch
29
CBA
feature
master git checkout –b feature
git reset B --hard
![Page 30: Git like a Pro (How to use it as it was meant to)](https://reader034.vdocuments.mx/reader034/viewer/2022050613/587ace0a1a28ab760f8b621f/html5/thumbnails/30.jpg)
29-1-2016
Extract committed changes
CBA
Bfeature
master
C’
git checkout B –b feature
git rebase A -i
![Page 31: Git like a Pro (How to use it as it was meant to)](https://reader034.vdocuments.mx/reader034/viewer/2022050613/587ace0a1a28ab760f8b621f/html5/thumbnails/31.jpg)
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
![Page 32: Git like a Pro (How to use it as it was meant to)](https://reader034.vdocuments.mx/reader034/viewer/2022050613/587ace0a1a28ab760f8b621f/html5/thumbnails/32.jpg)
29-1-2016
Not for the faint of heart
![Page 33: Git like a Pro (How to use it as it was meant to)](https://reader034.vdocuments.mx/reader034/viewer/2022050613/587ace0a1a28ab760f8b621f/html5/thumbnails/33.jpg)
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-urlgit clone –recursive sub-repo-urlgit config submodule.subrepo.url alternative-urlgit submodule update --remote
[submodule “subrepo"] path = .\subrepourl = https://github.com/subrepobranch = feature
git config submodule.DbConnector.url PRIVATE_URL
![Page 34: Git like a Pro (How to use it as it was meant to)](https://reader034.vdocuments.mx/reader034/viewer/2022050613/587ace0a1a28ab760f8b621f/html5/thumbnails/34.jpg)
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
![Page 35: Git like a Pro (How to use it as it was meant to)](https://reader034.vdocuments.mx/reader034/viewer/2022050613/587ace0a1a28ab760f8b621f/html5/thumbnails/35.jpg)
29-1-2016
How we like to work
![Page 36: Git like a Pro (How to use it as it was meant to)](https://reader034.vdocuments.mx/reader034/viewer/2022050613/587ace0a1a28ab760f8b621f/html5/thumbnails/36.jpg)
29-1-2016
How I like to work
Central Repo
John’s fork
Dean’s fork
mast
er
mast
er
share
d
Dean’s changes
Mike’s changes
Task
1
git rebase -i
Mike’s fork
Task
2
git rebase -i
Pull Request
Pull Request
Task
3
Pull Request
Pull Request
John’s changes
![Page 37: Git like a Pro (How to use it as it was meant to)](https://reader034.vdocuments.mx/reader034/viewer/2022050613/587ace0a1a28ab760f8b621f/html5/thumbnails/37.jpg)
29-1-2016
![Page 38: Git like a Pro (How to use it as it was meant to)](https://reader034.vdocuments.mx/reader034/viewer/2022050613/587ace0a1a28ab760f8b621f/html5/thumbnails/38.jpg)
Resources
• A scalable software development organization by using Githttp://www.continuousimprover.com/2015/03/a-scalable-software-development.html
• Why should abandon TFS Source Control and adopt Githttp://www.continuousimprover.com/2015/06/why-you-should-abandon-tfs-source.html
• Semantic Mergehttps://www.semanticmerge.com/
• Git Aliaseshttp://haacked.com/archive/2014/07/28/github-flow-aliases/
• Awesome Git tutorialshttp://pcottle.github.io/learnGitBranching/
• GitVersionhttps://github.com/GitTools/GitVersion
• Semantic Versioninghttp://semver.org/
• GitFlow vs GitHubFlowhttp://gitversion.readthedocs.org/en/latest/git-branching-strategies/
• Pro Git (the book)https://git-scm.com/book/en/v2
38
![Page 39: Git like a Pro (How to use it as it was meant to)](https://reader034.vdocuments.mx/reader034/viewer/2022050613/587ace0a1a28ab760f8b621f/html5/thumbnails/39.jpg)
How to find me?
39
• @ddoomen
• www.continuousimprover.com
• www.csharpcodingguidelines.com
• github.com/dennisdoomen
• www.fluentassertions.com
![Page 40: Git like a Pro (How to use it as it was meant to)](https://reader034.vdocuments.mx/reader034/viewer/2022050613/587ace0a1a28ab760f8b621f/html5/thumbnails/40.jpg)
29-1-2016
Thanks!
![Page 41: Git like a Pro (How to use it as it was meant to)](https://reader034.vdocuments.mx/reader034/viewer/2022050613/587ace0a1a28ab760f8b621f/html5/thumbnails/41.jpg)
Knowledge. People. Solutions.