Skip to content

lab 30 Merging

Goals

Merge the branches

Merging brings the changes in two branches together. Let’s go back to the greet branch and merge main onto greet.

Execute:

git checkout greet
git merge main
git hist --all

Output:

$ git checkout greet
Switched to branch 'greet'
$ git merge main
Merge made by the 'ort' strategy.
 README | 1 +
 1 file changed, 1 insertion(+)
 create mode 100644 README
$ git hist --all
*   b1df40e 2022-10-24 | Merge branch 'main' into greet (HEAD -> greet) [Jim Weirich]
|\  
| * 62f7394 2022-10-24 | Added README (main) [Jim Weirich]
* | 18e7dbd 2022-10-24 | Updated Rakefile [Jim Weirich]
* | 2a024f1 2022-10-24 | Hello uses Greeter [Jim Weirich]
* | 85316c2 2022-10-24 | Added greeter class [Jim Weirich]
|/  
* 0022837 2022-10-24 | Added a Rakefile. [Jim Weirich]
* 3172288 2022-10-24 | Moved hello.rb to lib [Jim Weirich]
* 3e56dbf 2022-10-24 | Add an author/email comment [Jim Weirich]
* 1dee7f9 2022-10-24 | Tell user how many names they have (tag: v1) [Jim Weirich]
* c72af6b 2022-10-24 | Rename variable to match its usage (tag: v1-beta) [Jim Weirich]
* 8cdd2cd 2022-10-24 | Can specify multiple names [Jim Weirich]
* 28fe396 2022-10-24 | Added a comment [Jim Weirich]
* 15c7573 2022-10-24 | Added a default value [Jim Weirich]
* 7d55044 2022-10-24 | Using ARGV [Jim Weirich]
* 91b926e 2022-10-24 | First Commit [Jim Weirich]

By merging main into your greet branch periodically, you can pick up any changes to main 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 main conflict with the changes in greet?