Your branch and ‘origin/dev’ have diverged …
Bij git status, en na een fetch:
git status
On branch dev
Your branch is ahead of ‘origin/dev’ by 2 commits.
(use “git push” to publish your local commits)
nothing to commit, working tree clean
git fetch
remote: Enumerating objects: 60, done.
remote: Counting objects: 100% (60/60), done.
remote: Compressing objects: 100% (42/42), done.
remote: Total 43 (delta 29), reused 1 (delta 0)
Unpacking objects: 100% (43/43), done.
From gitlab.com:GrpE3/e3
5f82217..4df07f6 dev -> origin/dev
65ecfe5..d86a92f dayreqflow -> origin/dayreqflow
git status
On branch dev
Your branch and ‘origin/dev’ have diverged,
and have 2 and 8 different commits each, respectively.
(use “git pull” to merge the remote branch into yours)
nothing to commit, working tree clean
Check waar het mogelijk aan ligt – hier een lokale commit (zonder push) en ondertussen commits op origin – met bv oa:
git log -3
git log --name-status HEAD^..HEAD
git rebase origin/dev
First, rewinding head to replay your work on top of it…
Applying: correct quote signs in changes.sql
Using index info to reconstruct a base tree…
M Changes.sql
.git/rebase-apply/patch:9: trailing whitespace.
ALTER TABLE `reqproc` CHANGE `name` `process` CHAR(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL;
warning: 1 line adds whitespace errors.
Falling back to patching base and 3-way merge…
Auto-merging Changes.sql
CONFLICT (content): Merge conflict in Changes.sql
error: Failed to merge in the changes.
Patch failed at 0001 correct quote signs in changes.sql
The copy of the patch that failed is found in: .git/rebase-apply/patchWhen 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”.
(Corrigeer bestand Changesl.sql)
git rebase --continue
Changes.sql: needs merge
You must edit all merge conflicts and then
mark them as resolved using git add
git status
rebase in progress; onto 4df07f6
You are currently rebasing branch ‘dev’ on ‘4df07f6’.
(fix conflicts and then run “git rebase –continue”)
(use “git rebase –skip” to skip this patch)
(use “git rebase –abort” to check out the original branch)Unmerged paths:
(use “git reset HEAD…” to unstage)
(use “git add…” to mark resolution) both modified: Changes.sql
no changes added to commit (use “git add” and/or “git commit -a”)
git add Changes.sql
git commit -am "fix Changes.sql diverged"
[detached HEAD b351146] fix Changes.sql diverged
1 file changed, 1 insertion(+), 2 deletions(-)
git status
rebase in progress; onto 4df07f6
You are currently rebasing branch ‘dev’ on ‘4df07f6’.
(all conflicts fixed: run “git rebase –continue”)
nothing to commit, working tree clean
git rebase --continue
Applying: correct quote signs in changes.sql
No changes – did you forget to use ‘git add’?
If there is nothing left to stage, chances are that something else
already introduced the same changes; you might want to skip this 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”.
git rebase --skip
Dat deed het uiteindelijk, en het Changes.sql bestand eindigde juist.
Nb: Zoals ze ook in dit artikel proberen uit te leggen, is er niet één bepaalde oplossing voor een diverge; je moet altijd onderzoeken wat er juist aan de hand is en hoe je het moet oplossen:
Dealing with diverged git branches
Ze zegt daarin (werkend op een “main”):
– wil je de wijzigingen van de twee uiteenlopende versies bijhouden in de uiteindelijke versie : git pull --rebase
– je wil de “remote changes” niet, en je eigen lokale versie/wijzigingen moet primeren: git push --force
, maar er zijn bedenkingen als je niet weet wat je doet met rebase
– je wil je eigen versie vergeten, en de “remote changes” binnenhalen: git reset --hard origin/main