Abdelaziz Mokhnache Abdelaziz Mokhnache - 25 days ago 7
Git Question

can not solve git conflicts when pulling from remote repo

when I pull the last commits I got the following error message:

C:\laragon\www\wordpress\wp-content\themes\chihab-twig>git pull
First, rewinding head to replay your work on top of it...
Applying: disable Timber cache
Using index info to reconstruct a base tree...
M functions.php
Falling back to patching base and 3-way merge...
Auto-merging functions.php
CONFLICT (content): Merge conflict in functions.php
error: Failed to merge in the changes.
Patch failed at 0001 disable Timber cache
The copy of the patch that failed is found in: .git/rebase-apply/patch

When you have resolved this problem, run "git rebase --continue".
If you prefer to skip this patch, run "git rebase --skip" instead.
To check out the original branch and stop rebasing, run "git rebase --abort".


When I fixed the conflict in my text editor and committed the changes, I got the following message:

[detached HEAD b66d68b] fix conflict
1 file changed, 4 insertions(+)


but when I switched to "master", I found that no changes were pulled.
what's wrong with this ?

Answer

Your default merge strategy has been set to rebase rather than merge.

The procedure for the rebase is different to a merge. A rebase goes back to where your changes originated (the rewinding HEAD message in the output) and then applies each commit's changeset in sequence. It stops if there is a conflict that it can't resolve automatically. That's where you're up to.

When you've made your changes (resolved the conflicts), use git add my/file and then git rebase --continue to complete the merge.

It essentially places the resolution of the conflict in the commit where the conflict arose. It's as though the conflict never happened - your changes are now based on a different starting point to what you began with.

You may consider changing your merge strategy to the default to avoid having to rebase. Wether to rebase or do a regular merge is a decision based on many factors (beyond the scope of this question).