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
*   19cb822 2020-05-30 | Merge branch 'master' into greet (HEAD -> greet) [Jim Weirich]
|\  
| * 32cb785 2020-05-30 | Added README (master) [Jim Weirich]
* | 4721c3f 2020-05-30 | Updated Rakefile [Jim Weirich]
* | 4689e1b 2020-05-30 | Hello uses Greeter [Jim Weirich]
* | e685fb0 2020-05-30 | Added greeter class [Jim Weirich]
|/  
* 128a484 2020-05-30 | Added a Rakefile. [Jim Weirich]
* a3cf03d 2020-05-30 | Moved hello.rb to lib [Jim Weirich]
* 96c1fec 2020-05-30 | Add an author/email comment [Jim Weirich]
* 9811d9e 2020-05-30 | Added a comment (tag: v1) [Jim Weirich]
* 3344f03 2020-05-30 | Added a default value (tag: v1-beta) [Jim Weirich]
* 3cb4c15 2020-05-30 | Using ARGV [Jim Weirich]
* dfb5614 2020-05-30 | 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?