Search⌘ K
AI Features

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) to Crispy 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.

Shell
git commit -a -m “I want Ripple Chips”

The output will be something like this:

Command's Parameters

Command / Parameter

Description

commit

This creates a new commit in the current branch.

-a

This stages all the modified files prior to the commit.

-m

This sets a commit message from the command line.

"I want Ripple Chips"

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.

Shell
git checkout newbranch

When we execute the command above, the output will be something like this:

Command's Parameters

Command / Parameter

Description

checkout

This checks out a commit or switches to a branch.

newbranch

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) to Crispy Chips:
...