Git Tutorial

Merging in git

To learn how to merge two distinct branches to restore changes to a single branch.

Step1:Merging to a single branch

Merging brings changes from two branches into one. Let us go back to the style branch and merge it with master.


git checkout style
git merge master
git hist --all


$ git checkout style
Switched to branch 'style'
$ git merge master
Merge made by recursive.
 README |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
 create mode 100644 README
$ git hist --all
*   5813a3f 2020-01-09 | Merge branch 'master' into style (HEAD, style) [kwikl3arn]
| * 6c0f848 2020-01-09 | Added README (master) [kwikl3arn]
* | 07a2a46 2020-01-09 | Updated index.html [kwikl3arn]
* | 649d26c 2020-01-09 | Hello uses style.css [kwikl3arn]
* | 1f3cbd2 2020-01-09 | Added css stylesheet [kwikl3arn]
* 8029c07 2020-01-09 | Added index.html. [kwikl3arn]
* 567948a 2020-01-09 | Moved hello.html to lib [kwikl3arn]
* 6a78635 2020-01-09 | Add an author/email comment [kwikl3arn]
* fa3c141 2020-01-09 | Added HTML header (v1) [kwikl3arn]
* 8c32287 2020-01-09 | Added standard HTML page tags (v1-beta) [kwikl3arn]
* 43628f7 2020-01-09 | Added h1 tag [kwikl3arn]
* 911e8c9 2020-01-09 | First Commit [kwikl3arn]

Through periodic master branch merging with the style branch you can pick up any changes or modifications to the master to maintain compatibility with the style changes in the mainline.

However, this makes the commit graphics look ugly. Later we will consider relocation as an alternative to fusion.


But what if changes to the master branch conflict with changes in style?