Skip to content
Discussion options

You must be logged in to vote

This happens because git rebase replays each commit linearly, including the merge commit (which is just another commit with two parents). When Git replays the merge commit, it has to re-merge the branches, which causes the conflict again.

Solution 1: Remove the merge commit (cleanest)

# Option A: Squash the merge commit away
git rebase -i main
# Mark the merge commit as 'squash' or 'd' (delete) in the interactive editor
# Git will replay the other commits cleanly

# Option B: Cherry-pick individual commits
git rebase --abort  # Stop the current rebase
git reset --hard HEAD  # Go back to original state
git log --oneline  # Find the commits you want
git checkout -b clean-feature
git cherry-…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by augustbreay
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issues Repository issues let you track features, problems, and more alongside your code Question Ask and answer questions about GitHub features and usage source:ui Discussions created via Community GitHub templates
3 participants