GitHub can’t rebase my feature branch: “This branch cannot be rebased due to conflicts”

If you created the branch from main but you now need to rebase onto main then main must have been updated since you created your branch. The conflicts come from those changes.

I understand that this can be resolved by:

git checkout main
git rebase feature/x
(resolve conflicts)

This isn’t correct. This would rebase main onto feature/x; you need to rebase feature/x onto main.

Instead,

  1. update your local main from GitHub before the rebase by pulling it or similar,
  2. check feature/x out,
  3. run git rebase main, and
  4. resolve conflicts.

Then push your feature branch to GitHub (you’ll need to use --force-with-lease since this rewrites commit hashes). The pull request will be updated accordingly.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)