Loading...

Git Tutorial

Merging to the Master branch in git

We have kept our style branch up to date with the master branch (using rebase), but now let's merge the style branch changes back into the master.

Step1:Merging style into master

RUN:

git checkout master
git merge style

RESULT:

$ git checkout master
Switched to branch 'master'
$ git merge style
Updating 6c0f848..6e6c76a
Fast-forward
 index.html     | 2 +-
 lib/style.css  | 8 ++++++++
 lib/hello.html | 6 ++++--
 3 files changed, 13 insertions(+), 3 deletions(-)
 create mode 100644 lib/style.css

Since the last master commit directly precedes the last commit of the style branch, git can merge fast-forward by simply moving the branch pointer forward, pointing to the same commit as the style branch.

Conflicts do not arise in the fast-forward merge.


Step2:Check the logs

RUN:

git hist

RESULT:

$ git hist
* 6e6c76a 2020-01-09 | Updated index.html (HEAD, master, style) [kwikl3arn]
* 1436f13 2020-01-09 | Hello uses style.css [kwikl3arn]
* 59da9a7 2020-01-09 | Added css stylesheet [kwikl3arn]
* 6c0f848 2020-01-09 | Added README [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]

Now style and master are identical.