Loading...

Git Tutorial

Creating a conflict in git

Creating a conflicting of changes in the master branch.

Step1:Return to the master and create conflict

Return to the master branch and make the following changes:

git checkout master

FILE: lib/hello.html

<!-- Author: kwikl3arn (kwikl3arn@gmail.com) -->
<html>
  <head>
    <!-- no style -->
  </head>
  <body>
    <h1>Hello, World! Life is great!</h1>
  </body>
</html>

RUN:

git add lib/hello.html
git commit -m 'Life is great!'

(Warning: make sure you've used single-quotes to avoid problems with bash and the ! character)


Step2:View branches

RUN:

git hist --all

RESULT:

$ git hist --all
* 454ec68 2020-01-09 | Life is great! (HEAD, master) [kwikl3arn]
| * 5813a3f 2020-01-09 | Merge branch 'master' into style (style) [kwikl3arn]
| |\  
| |/  
|/| 
* | 6c0f848 2020-01-09 | Added README [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]

After the Added README commit, the master branch has been merged with the style branch, but there is an additional master commit, which was not merged back to the style branch.

Next

The last change in master conflicts with some changes in style. In the next step we will solve this conflict.