Notebooks
Miscellaneous
Git: Branch reconciling

Git Error: You have divergent branches and need to specify how to reconcile them.

When working with local and remote branches in Git, you might encounter this error when pushing or pulling from the remote (GitHub).

Rebase error

What happened?

  • Your local branch and the branch on GitHub (remote branch) have different changes.
  • Git doesn't know how to combine (reconcile) these changes.

Why it matters?

  • You need to decide how to merge these changes so both branches are up to date.

How to fix?

  1. Merge: Combine changes and keep all commits (default strategy).

Merge

git pull --no-rebase origin main
 
#or
 
git pull origin main
  1. Rebase: Move your changes on top of the remote changes, creating a straight line of commits.

Rebase

git pull --rebase origin main
  1. Fast-forward: Only update if there are no new local changes.

ff

git pull --ff-only origin main

Summary

Choose a strategy (merge, rebase, or fast-forward) to update your branch.