Mastering Git
Mastering Git
Mastering Git
02 Branching Strategy
03 Pull Requests
04 Merge Conflicts
05 Merge vs Rebase
#1 The Perfect Commit
C C C C
Integrating changes and structuring release
C
Feature branch
C
C
Dev branch
C
C
Main branch
C C
Integrating changes and structuring release
C
Feature
C
C branch
Dev branch
C
C
Main branch
C C
Integrating changes and structuring release
C
Feature
C
C branch
Dev branch
C
C
Main branch
C C
Branch strategies : ONE
GitHub Flow
→ very simple, very lean: only one long-running branch (“main”) + feature
branches
Bugfix branch
C C C C
Feature branch
C C
C
Branch strategy: TWO
GitFlow
→ more structure, more rules
→ long-running: “main” + “dev”
→ short-lived: features, releases, hotfixes
C
C C C Release branch
C
Feature branch
C
C
Dev branch
C
C C
Main branch
#3 Pull Request
Used for communicating about and reviewing code - without pull request you would jump to
merging your code…
A way to contribute to repository you don’t have access to - through forks where one of the
main contributor can review your code and approve you submission into the main repo.
#4 Merge conflict
$ git merge
$ git rebase
$ git cherry-pick
$ git pull
→ Failed merge
→ Updating the same file o
Used for communicating about and reviewing code - without pull request you would jump to
merging your code…
A way to contribute to repository you don’t have access to - through forks where one of the
main contributor can review your code and approve you submission into the main repo.
Merge & rebase
C2 C3 Branch B
Branch A
C1 C2 C3
Branch B
Merge & rebase
C2 C3
C1 C3
C2 C4
Merge & rebase
Rebase
→ Step one
C3
C1
C2 C4
C1
C2 C4
branch A
C1 C2 C4
branch B
Merge & rebase
branch A
C3
C1 C2 C4
branch B
Take note!
Do not use Rebase for commits you have already shared or pushed on remote repository
Use Rebase for cleaning local commit history before sharing it to your team repository