Happens when working on a team project when two/more developers have edited the same file.
Therefore, face the conflict courageously.
Assumption: current_branch
(local branch) conflicts with a base branch called base-branch
git pull origin --rebase base-branch
. If your local base-branch is upto date with origin, you can just dogit rebase base-branch
If merge conflicts persist:- Fix merge conflicts by accepting either
current changes
,incoming changes
orAccept both changes
. Remember to cosult when fixing conflicts because you might end up removing crucial code. git add .
all the changes that you have made.git rebase --continue
to continue fixing merge conflicts.- If merge conflict persists, repeat steps 2 to 4.
- If merge conflict is fixed then
git push --force-with-lease current_branch
.
Nice job. This will be very beneficial for all of us moving forward.