Skip to content

lab 26 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 'recursive' strategy.
 README | 1 +
 1 file changed, 1 insertion(+)
 create mode 100644 README
$ git hist --all
*   8c53c97 2019-06-27 | Merge branch 'main' into greet (HEAD -> greet) [Halle Bot]
|\  
| * 3aa3064 2019-06-27 | Added README (main) [Halle Bot]
* | f52644d 2019-06-27 | Updated package [Halle Bot]
* | 455c54f 2019-06-27 | Hello uses Greeter [Halle Bot]
* | 4fb8bde 2019-06-27 | Added greeter class [Halle Bot]
|/  
* 2b04803 2019-06-27 | Added a package.json. [Halle Bot]
* b65b430 2019-06-27 | Moved hello.js to lib [Halle Bot]
* 4535421 2019-06-27 | Add an author/email comment [Halle Bot]
* 59992ce 2019-06-27 | Added a comment (tag: v1) [Halle Bot]
* 20a6c79 2019-06-27 | Added a default value (tag: v1-beta) [Halle Bot]
* 6915d41 2019-06-27 | Using process.argv [Halle Bot]
* 284070d 2019-06-27 | First Commit [Halle Bot]

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?