0% found this document useful (0 votes)
52 views

Module 3 - Git and Jenkins - Assignment 1

Hooli Co. has assigned Harry and Kane to implement new features, but they worked separately and made copies of the source code. Now it is difficult to track changes and merge the code. The document provides steps to: 1) Create two branches from master; 2) Make changes to the same file in both branches; 3) Merge the first branch successfully but 4) Merging the second branch causes a conflict; 5) Resolve the conflict using a merge tool.

Uploaded by

Darbha Preetham
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
52 views

Module 3 - Git and Jenkins - Assignment 1

Hooli Co. has assigned Harry and Kane to implement new features, but they worked separately and made copies of the source code. Now it is difficult to track changes and merge the code. The document provides steps to: 1) Create two branches from master; 2) Make changes to the same file in both branches; 3) Merge the first branch successfully but 4) Merging the second branch causes a conflict; 5) Resolve the conflict using a merge tool.

Uploaded by

Darbha Preetham
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Problem Statement

Hooli Co. has put Harry and Kane to implement a new set of features in their feature
software. Both started working separately, making their copies of the same source
code. Now, it has become difficult for them to track the changes they’ve made in the
original code, and they are finding it difficult to merge their code.

Action Items

• Create two separate branches from the master.


• Make changes in the same function of the source code in both branches.
• Merge branch1 into the master.
• Try and merge branch2 into the master (merge conflict should arise).
• Install a merge tool of your choice and resolve the merge conflict using the git
mergetool command.

1) Create two separate branches from the master.

- git checkout main


- git pull origin main
- git checkout -b branch1
- git checkout -b branch2
- git commit -m “Added 2 branches”
- git log –oneline main (to check the commits).

2) Make changes in the same function of the source code in both branches.

- Changed the line on index.html on both branches.


- vim index.html
- git add .

3) Merge branch1 into the master.

- Commit and push the changes from branch1 to main branch.


- git checkout main
- git pull origin main
- git merge branch1
- git push origin master
4) Try and merge branch2 into the master (merge conflict should arise).

- git checkout main


- git pull origin main
- git merge branch2
- Error message : darbhapreetham@Darbhas-MacBook-Pro sample-
project_2 % git merge branch2
Auto-merging sample-project_2/index.html
CONFLICT (add/add): Merge conflict in sample-project_2/index.html
Automatic merge failed; fix conflicts and then commit the result.
-

5) Install a merge tool of your choice and resolve the merge conflict using the
git mergetool command.

- On MacOS, to install the merge tool, the command is


- Brew install meld(it is one of the merge tool).
-

- git mergetool
- Make necessary changes and save the file.
- Complete the merge.
- Commit the changes
- git merge --continue
- git push origin main
-
- You can check the Git repo here:
“https://github.com/DarbhaPreetham/Sample_Project_1”.

You might also like