Skip to content

lab 28 Merging

Goals

Merge the branches

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 the 'recursive' strategy.
 README | 1 +
 1 file changed, 1 insertion(+)
 create mode 100644 README
$ git hist --all
*   2424440 2018-09-28 | Merge branch 'master' into greet (HEAD -> greet) [Jim Weirich]
|\  
| * 5c40874 2018-09-28 | Added README (master) [Jim Weirich]
* | 3f038a4 2018-09-28 | Updated Rakefile [Jim Weirich]
* | fa0b537 2018-09-28 | Hello uses Greeter [Jim Weirich]
* | 6f9af14 2018-09-28 | Added greeter class [Jim Weirich]
|/  
* 191f0c6 2018-09-28 | Added a Rakefile. [Jim Weirich]
* ef98cae 2018-09-28 | Moved hello.rb to lib [Jim Weirich]
* e1e08fd 2018-09-28 | Add an author/email comment [Jim Weirich]
* 7bf0bf1 2018-09-28 | Added a comment (tag: v1) [Jim Weirich]
* 9cf3f21 2018-09-28 | Added a default value (tag: v1-beta) [Jim Weirich]
* 94e1b8b 2018-09-28 | Using ARGV [Jim Weirich]
* f656098 2018-09-28 | 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

But first, what if the changes in master conflict with the changes in greet?