4. How to merge
• It’s simple!
1. Make sure the source and destination branch are
up to date
2. Merge and solve conflicts
3. Run all the tests
4. Push to remote repository
5. How to merge
1. Make sure the source and destination branch are up
to date
; deal with the source_branch
•
•
git checkout source_branch
git pull --rebase origin source_branch
; deal with the destination_branch
•
git checkout destination_branch
•
git pull --rebase origin destination_branch
; sometimes the branches are not updated so we (always) need to:
•
git fetch
6. How to merge
2. Merge and solve conflicts
•
git merge --no-ff source_branch
•
Optional (only if you have conflicts):
–
–
–
git mergetool –y
git add -A <all the files that had a conflict>
git commit -sv
7. How to merge
3. Run all the tests
•
•
gradlew --offline clean check
gradlew --offline clean runPdiTests
•
If tests fail: FIX THEM before you continue!
8. How to merge
4. Push to remote repository
•
git push origin destination_branch
9. How to merge
Stuff that can go wrong
someone might have pushed something while
you were doing the merge
10. How to merge
How to deal with this
• Simple solution: before a merge tell the team
not to put anything on the destination branch
• Not so simple: reset everything and start again
– git checkout destination_branch
– git reset --hard origin/destination_branch
– start over (update the branches, etc)
12. Branches with one commit
• NO!
If you have a single commit do NOT create a
new branch.
If you do create a new branch you should use:
git merge source_branch
instead of
git merge --no-ff source_branch
13. Branches with one commit
Simple rule
–
–
1 commit --> no branch
> 1 commit --> create branch