Resolve conflicts during Git merge and rebase
Vishal Bhavsar
Posted on July 5, 2024
Say, you have main
& feature
as 2 branches.
Merge conflicts
If you want to merge feature
branch into main
, run following command.
git checkout main
git merge feature
This can result in merge conflicts.
To discard all changes in feature
and accept everything on main
, run following command.
git merge -Xours feature
To accept changes from feature
branch, run below command.
git merge -Xtheirs feature
Rebase conflicts
If you want to rebase feature
branch onto main
, run below command.
git checkout feature
git rebase main
Again, this can result in merge conflicts.
To accept the changes in feature
branch, run below command.
git rebase main -Xtheirs
To accept the changes in main
branch, run below command.
git rebase main -Xours
💖 💪 🙅 🚩
Vishal Bhavsar
Posted on July 5, 2024
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.
Related
githubcopilot AI Innovations at Microsoft Ignite 2024 What You Need to Know (Part 2)
November 29, 2024