lab 13 Merging
Goals
- Learn how to merge two diverging branches to bring the changes back into a single branch.
Merge the branches 01
Merging brings the changes in two branches together. Let’s go back to the greet branch and merge master onto greet.
Execute:
git checkout greet git merge master git hist --all
Output:
$ git checkout greet Switched to branch 'greet' $ git merge master Merge made by recursive. README | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) create mode 100644 README $ git hist --all * a39d82c 2015-09-29 | Merge branch 'master' into greet (HEAD -> greet) [Jim Weirich] |\ | * 05a03bd 2015-09-29 | Added README (master) [Jim Weirich] * | 8d1dc1f 2015-09-29 | Hello uses greet function [Jim Weirich] * | 8c0391e 2015-09-29 | Added greeter function [Jim Weirich] |/ * 1a0bf04 2015-09-29 | Using argv [Jim Weirich] * 55a75e6 2015-09-29 | First commit [Jim Weirich]
By merging master into your greet branch periodically, you can pick up any changes to master and keep your changes in greet compatible with changes in the mainline.
However, it does produce ugly commit graphs. Later we will look at the option of rebasing rather than merging.
Up Next 02
But first, what if the changes in master conflict with the changes in greet?