Skip to content

lab 25 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
*   33134b5 2023-08-21 | Merge branch 'main' into greet (HEAD -> greet) [Théophile Chevalier]
|\  
| * 6179ba3 2023-08-21 | Added README (main) [Théophile Chevalier]
* | cc98109 2023-08-21 | Hello uses Greeter [Théophile Chevalier]
* | d6aae18 2023-08-21 | Add greeter class [Théophile Chevalier]
|/  
* 9ab61ca 2023-08-21 | Moved hello.py to lib [Théophile Chevalier]
* 7abea37 2023-08-21 | Add an author/email comment [Théophile Chevalier]
* 1c410c6 2023-08-21 | Add a comment (tag: v1) [Théophile Chevalier]
* 0bf384c 2023-08-21 | Display user input (tag: v1-beta) [Théophile Chevalier]
* 31c3945 2023-08-21 | Add some content [Théophile Chevalier]
* aa5d425 2023-08-21 | First Commit [Théophile Chevalier]

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?