CodeBlanks Logo Icon CodeBlanks

Conflict

Resolve a merge conflict and complete the commit.

Resolving a merge conflict

A merge conflict can occur when two branches modify the same sections of a file differently. Git pauses the merge and waits for you to edit the conflicted files. After keeping the desired content, stage the file and complete the merge with a commit.

git merge feature/payment
# Edit the file
git add payment.js
git commit -m "merge: resolve payment conflict"

Practice Record the conflict resolution

Assume that you have resolved the merge conflict in settings.js. Stage the file and create a commit with the message fix: resolve settings conflict.

Starter code

terminal
# Çözülmüş dosyayı sahnele

# Çözüm commit'ini oluştur

Sample solution

terminal
git add settings.js
git commit -m "fix: resolve settings conflict"

Expected output

settings.js staged.
Conflict resolution committed.

Practice Complete the merge process

Merge the feature/settings branch into the current branch. After resolving the conflict, stage settings.js and create a commit with the message merge: complete settings update.

Starter code

terminal
# Özellik dalını birleştir

# Çözülmüş dosyayı sahnele

# Birleştirmeyi commit et

Sample solution

terminal
git merge feature/settings
git add settings.js
git commit -m "merge: complete settings update"

Expected output

Merge started.
settings.js staged.
Merge completed.

Questions and answers

Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.

1 After resolving a merge conflict, which sequence completes the merge commit?

  • Stage the file and create a commit Correct answer
  • Remove and re-add the remote
  • Delete the tag and rename the branch
  • Delete the file and create a new repository

Explanation: After editing the conflicted file, stage it with git add and complete the merge with git commit.

2 Stage the resolved file

Question
git add ____
Answer
git add payment.js

Explanation: After resolving the conflict, the edited file itself must be staged.

3 Merge conflict stages

Term Meaning
Çatışma Overlapping changes
Düzenleme Keeping the desired content
Sahneleme Recording the resolution in Git
Commit Completing the merge

All lessons in Intermediate

20 Intermediate final

  1. Branch management
  2. Rebase
  3. Conflict
  4. PR flow