git pull merge conflicts
While following a large github repository, I seem to frequently get my local repository into an un-mergeable state, where apparently no combination of git pull
, git merge
, git reset
, git clean
, git checkout
, no matter the options, fails to allow a git pull
to succeed.
Note: These merge conflicts should not happen, and are likely a symptom of checksums of old commits changing. This should not generally happen. In this case, the pulled repository is the result of a repository being converted from an alternate VCS (CVS, Mercurial, etc), periodically exported and imported into git.
bash$ git pull
remote: Counting objects: 220, done.
remote: Compressing objects: 100% (19/19), done.
remote: Total 220 (delta 194), reused 219 (delta 193), pack-reused 0
Receiving objects: 100% (220/220), 502.48 KiB | 620.00 KiB/s, done.
Resolving deltas: 100% (194/194), completed with 62 local objects.
From github.com:NetBSD/src
69222a8a366e..0e4aa768536f trunk -> origin/trunk
1a40b30119fc..f66452f409c4 KRISTAPS -> origin/KRISTAPS
error: The following untracked working tree files would be overwritten by merge:
external/gpl3/binutils.old/dist/bfd/doc/aoutx.texi
external/gpl3/binutils.old/dist/bfd/doc/archive.texi
external/gpl3/binutils.old/dist/bfd/doc/archures.texi
external/gpl3/binutils.old/dist/bfd/doc/bfdio.texi
external/gpl3/binutils.old/dist/bfd/doc/bfdt.texi
…
bash$ git clean -f -d
…
Removing external/gpl3/binutils.old/dist/
bash$ git status
On branch trunk
Your branch and 'origin/trunk' have diverged,
and have 31089 and 37860 different commits each, respectively.
(use "git pull" to merge the remote branch into yours)
nothing to commit, working tree clean
And another failure:
ksh$ git pull
remote: Enumerating objects: 5812, done.
remote: Counting objects: 100% (5812/5812), done.
remote: Compressing objects: 100% (370/370), done.
remote: Total 18017 (delta 5526), reused 5699 (delta 5422), pack-reused 12205
Receiving objects: 100% (18017/18017), 9.60 MiB | 3.26 MiB/s, done.
Resolving deltas: 100% (11460/11460), completed with 2232 local objects.
From github.com:NetBSD/src
…
Auto-merging distrib/notes/common/legal.common
CONFLICT (content): Merge conflict in distrib/notes/common/legal.common
Auto-merging distrib/notes/Makefile.inc
CONFLICT (content): Merge conflict in distrib/notes/Makefile.inc
warning: inexact rename detection was skipped due to too many files.
warning: you may want to set your merge.renamelimit variable to at least 19561 and retry the command.
Automatic merge failed; fix conflicts and then commit the result.
Since I have very few local changes, easily saved with git stash
, my solution, without deleting and starting again, is to re-branch, as follows:
bash$ git checkout -f
Checking out files: 100% (7365/7365), done.
Your branch and 'origin/trunk' have diverged,
and have 31089 and 37860 different commits each, respectively.
(use "git pull" to merge the remote branch into yours)
bash$ git reset
bash$ git branch -m trunk oldtrunk
bash$ git checkout trunk
Checking out files: 100% (82355/82355), done.
Branch 'trunk' set up to track remote branch 'trunk' from 'origin'.
Switched to a new branch 'trunk'
bash$ git pull
remote: Counting objects: 274, done.
remote: Compressing objects: 100% (41/41), done.
remote: Total 274 (delta 221), reused 253 (delta 215), pack-reused 15
Receiving objects: 100% (274/274), 55.18 KiB | 274.00 KiB/s, done.
Resolving deltas: 100% (221/221), completed with 120 local objects.
From github.com:NetBSD/src
0e4aa768536f..beb48fa8ba69 trunk -> origin/trunk
1e900ebcbb3e..df6593c151d1 phil-wifi -> origin/phil-wifi
Updating 0e4aa768536f..beb48fa8ba69
Fast-forward
bin/sh/eval.c | 22 +++++---
distrib/sets/lists/comp/ad.aarch64 | 10 ++--
distrib/sets/lists/comp/mi | 4 +-
distrib/sets/lists/man/mi | 8 +--
doc/3RDPARTY | 104 ++++++++++++++++++-----------------
…
bash$ git branch -D oldtrunk
Deleted branch oldtrunk (was 6a901eda34ec).