CodeBlanks Logo Icon CodeBlanks

Resolve conflicts

Resolve a conflict that arises during rebase.

Conflict during rebase

A conflict may occur when rebasing a feature branch onto an updated main branch if different changes affect the same lines. Git pauses the operation and waits for you to decide which changes to keep. After editing and saving the conflicted file, you can stage the resolution and continue the rebase.

git rebase main
# Resolve the conflict
git add index.html
git rebase --continue

Steps to resolve a conflict

In a conflicted file, the markers <<<<<<<, =======, and >>>>>>> show which sections conflict. Keep the desired content, remove these markers, and save the file. Finally, stage the file and continue the rebase.

git status
git add index.html
git rebase --continue

Practice Complete the rebase conflict resolution

Assume that you have resolved a conflict on the feature/cart branch. Stage the cart.js file and continue the rebase. Write the commands in the correct order.

Starter code

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

# Rebase işlemine devam et

Sample solution

terminal
git add cart.js
git rebase --continue

Expected output

cart.js staged.
Rebase completed successfully.

Questions and answers

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

1 Which command continues the operation after resolving a conflict during rebase?

  • git reset --hard
  • git branch -d
  • git merge --abort
  • git rebase --continue Correct answer

Explanation: After resolving the conflict and staging the file, git rebase --continue resumes the operation.

2 Continue the rebase after resolving a conflict

Question
git add index.html
git rebase ____
Answer
git add index.html
git rebase --continue

Explanation: After the conflict resolution is staged, --continue resumes the rebase process.

3 Rebase conflict operations

Term Meaning
git status Shows conflicted files
<<<<<<< Starts the current change section
git add Stages the resolved file
--continue Continues the rebase

All lessons in Intermediate

20 Intermediate final

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