Course contentsShow
← Data Science
Lesson 2018 of 2,14546. Version Control with GitFree lesson

Resolving Conflicts During Rebase

Step through the process of resolving conflicts during a rebase operation and continuing or aborting the rebase.

Resolving Conflicts During Rebase

You'll learn how to handle and resolve conflicts that arise mid-rebase, and how to continue or abort the operation.

What Happens When Rebase Hits a Conflict

Unlike a standard merge, a rebase replays commits one at a time onto a new base. If Git can't automatically apply a commit (because the same lines were changed differently), it pauses the rebase and asks you to resolve the conflict manually. Think of it like following a recipe step-by-step: if one ingredient is missing, you must handle that before proceeding to the next step.

When this happens, Git leaves you in a special "rebasing" state. Your repository isn't broken—it's just waiting for your decision.

The Resolution Workflow

  1. Identify conflicts: Run git status to see which files have conflicts (marked as "both modified")
  2. Open conflicting files: Look for conflict markers (<<<<<<<, =======, >>>>>>>) showing both versions
  3. Manually edit: Choose which changes to keep, or combine them, then remove the conflict markers
  4. Stage the resolved files: Use git add <filename> to mark conflicts as resolved
  5. Continue the rebase: Run git rebase --continue to move to the next commit

Git will repeat this process for each conflicting commit in your rebase sequence.

When You Need to Bail Out

If the conflicts are overwhelming or you realize the rebase was a mistake, you can abort at any time:

git rebase --abort

This returns your branch to exactly where it was before you started the rebase—like hitting undo on the entire operation.

Why This Matters in Data Science

When rebasing feature branches with analysis code or pipeline changes, conflicts in notebooks, scripts, or configuration files are common. Understanding the pause-resolve-continue cycle keeps your Git history clean without losing work.

Key Takeaway: During a rebase, conflicts pause the operation; resolve them file-by-file with git add and git rebase --continue, or use git rebase --abort to cancel the entire rebase safely.