lab 28 Merging
- Learn how to merge two diverging branches to bring the changes back into a single branch.
Merge the branches
Merging brings the changes in two branches together. Let’s go back to the greet branch and merge master onto greet.
git checkout greet git merge master git hist --all
$ git checkout greet Switched to branch 'greet' $ git merge master Merge made by the 'recursive' strategy. README | 1 + 1 file changed, 1 insertion(+) create mode 100644 README $ git hist --all * 69be050 2019-11-01 | Merge branch 'master' into greet (HEAD -> greet) [Jim Weirich] |\ | * 099ccd0 2019-11-01 | Added README (master) [Jim Weirich] * | 69a8d70 2019-11-01 | Updated Rakefile [Jim Weirich] * | 7b8b268 2019-11-01 | Hello uses Greeter [Jim Weirich] * | f84663f 2019-11-01 | Added greeter class [Jim Weirich] |/ * ed35144 2019-11-01 | Added a Rakefile. [Jim Weirich] * 4421854 2019-11-01 | Moved hello.rb to lib [Jim Weirich] * 185fc95 2019-11-01 | Add an author/email comment [Jim Weirich] * 4d578d4 2019-11-01 | Added a comment (tag: v1) [Jim Weirich] * dc1d42f 2019-11-01 | Added a default value (tag: v1-beta) [Jim Weirich] * 9a1c494 2019-11-01 | Using ARGV [Jim Weirich] * 063b40e 2019-11-01 | 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.
But first, what if the changes in master conflict with the changes in greet?