Suggest an editImprove this articleRefine the answer for “What is a conflict during rebase?”. Your changes go to moderation before they’re published.Approval requiredContentWhat you’re changing🇺🇸EN🇺🇦UAPreviewTitle (EN)Short answer (EN)**A conflict during** `git rebase` occurs when Git cannot apply the next commit on top of the new base, because the changes conflict with the existing code. **Key point:** a conflict during `git rebase` must be resolved manually before continuing the rebase.Shown above the full answer for quick recall.Answer (EN)Image**A conflict during** `git rebase` is a situation where Git **cannot apply the next commit on top of the new base**, because the changes **conflict with the existing code**. Simply put: Git tries to "replay" your commits one by one, and at some step they do not match the current state of the branch. --- ## When a conflict occurs during rebase A conflict appears if: - you are rebasing onto a branch where the code **has already changed significantly** - your commit changes the same lines as commits in the new base Unlike merge, the conflict does not occur **for the whole branch at once**, but **on a specific commit**. --- ## What happens during rebase When you run: ```bash git rebase main ``` Git: 1. takes the **first commit** of your branch 2. tries to apply it on top of `main` 3. if it fails, it **stops on that commit** 4. waits for you to resolve the conflict --- ## What a conflict looks like The file looks the same as during a merge: ```text <<<<<<< HEAD console.log("from main"); ======= console.log("from feature commit"); >>>>>>> commit_hash ``` The difference is in the context: - `HEAD` - the new base (`main`) - the lower part - the changes of **the specific commit** currently being applied --- ## How to resolve a conflict during rebase 1. Open the conflicting files 2. Fix the code 3. Remove the conflict markers 4. Add the files: ```bash git add file.js ``` 5. Continue the rebase: ```bash git rebase --continue ``` If you need to cancel: ```bash git rebase --abort ``` --- ## Key difference from a merge conflict | Merge | Rebase | |---|---| | The conflict is resolved once | Conflicts can occur **on every commit** | | Resolution -> one `git commit` | Resolution -> `git rebase --continue` | | The whole branch at once | Commits one at a time | --- ## Why rebase seems harder - there can be more conflicts - you need to understand **which commit you are on** - it is easy to get confused without experience However: - each conflict is **local and logical** - the resulting history is cleaner --- ## Interview phrasing > **A conflict during** `git rebase` **occurs when Git cannot apply the next commit on top of the new base, and requires manually resolving the conflict and continuing the rebase.**For the reviewerNote to the moderator (optional)Visible only to the moderator. Helps review go faster.