Post on 14-Jul-2015
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
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
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
How to merge
3. Run all the tests
• gradlew --offline clean check
• gradlew --offline clean runPdiTests
• If tests fail: FIX THEM before you continue!
How to merge
Stuff that can go wrong
someone might have pushed something while you were doing the merge
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)
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
Reverts
Reverting more than 1 PUSHED commit:
git revert <commit1 hash>
git revert <commit2 hash>
git rebase –i HEAD~2
; reword + fixup/squash