Git Kata 4: Merge Conflicts
Explore the process of handling merge conflicts in Git branches by working with changes in a shared file. Learn how to modify files in different branches, identify conflicts, and resolve them effectively through manual editing and committing. This lesson equips you to manage complex merges and maintain a clean commit history.
Step 1: Modify the file in the main branch
To append to the file and save:
- Add
(I want ripple chips)toCrispy Chips.Crispy Chips (I want ripple chips)- Save the changes.
This step adds a new comment to the Crispy Chips line.
The command to commit the change to the repository is given below.
The output will be something like this:
Command's Parameters
Command / Parameter | Description |
| This creates a new commit in the current branch. |
| This stages all the modified files prior to the commit. |
| This sets a commit message from the command line. |
| This is the commit message. |
This step commits the change made to the Crispy Chips line.
The output of the command is:
Output
Message | Meaning |
"[master 238996b] I want ripple chips" | This is the branch and abbreviated hash of the commit and the commit message. |
"1 file changed, 1 insertion(+), 1 deletion(-)" | This is the number of files changed and the number of insertions and deletions. |
Step 2: Modify the file in newbranch
The command to switch to newbranch is given below.
When we execute the command above, the output will be something like this:
Command's Parameters
Command / Parameter | Description |
| This checks out a commit or switches to a branch. |
| This is the branch to checkout. |
This command switches to newbranch.
To append in the file and save:
- Switch to the text editor and reload the file.
- Add
(I’ll take barbecue)toCrispy Chips: