28. Merging

Goals

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

01 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.

Run:

git checkout style
git merge master
git hist --all

Result:

$ 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 2011-03-09 | Merge branch 'master' into style (HEAD, style) [Marina Pushkova]
|\  
| * 6c0f848 2011-03-09 | Added README (master) [Marina Pushkova]
* | 07a2a46 2011-03-09 | Updated index.html [Marina Pushkova]
* | 649d26c 2011-03-09 | Hello uses style.css [Marina Pushkova]
* | 1f3cbd2 2011-03-09 | Added css stylesheet [Marina Pushkova]
|/  
* 8029c07 2011-03-09 | Added index.html. [Marina Pushkova]
* 567948a 2011-03-09 | Moved hello.html to lib [Marina Pushkova]
* 6a78635 2011-03-09 | Add an author/email comment [Marina Pushkova]
* fa3c141 2011-03-09 | Added HTML header (v1) [Marina Pushkova]
* 8c32287 2011-03-09 | Added standard HTML page tags (v1-beta) [Marina Pushkova]
* 43628f7 2011-03-09 | Added h1 tag [Marina Pushkova]
* 911e8c9 2011-03-09 | First Commit [Marina Pushkova]

Through periodic master branch merging with the style branch you can pick up to the master any changes or modifications 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.

02 Next

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

SVN?
© 2011-2014 Git How To. All rights reserved / Contact us