git Bug prevents merge

1.4k Views Asked by At

How can I do a git bisect on a git bug or otherwise restore my git index. Error message first, then failed attempts at a fix below

With GIT_MERGE_VERBOSITY=5 I run git merge origin master and get...

Merging:
9201eee porque no, "not and"
virtual origin
found 2 common ancestors:
21d206e (redo) merged in feature/edb and fixed the unit test. Also fixed a bug in bq where the imposition of the MIN_BUILDINGS constraint results in zero results, but an erroneous 'found_entities' field.
ac55def Merge pull request #276 from company/feature/chromeframe_support
  Merging:
  21d206e (redo) merged in feature/edb and fixed the unit test. Also fixed a bug in bq where the imposition of the MIN_BUILDINGS constraint results in zero results, but an erroneous 'found_entities' field.
  ac55def Merge pull request #276 from company/feature/chromeframe_support
  found 1 common ancestor:
  2f55197 Merge pull request #271 from company/feature/autobahn-host-as-setting
  Auto-merging requirements.unstable.txt
  Auto-merging requirements.txt
  Auto-merging project/tests/test_querier.py
  CONFLICT (content): Merge conflict in project/tests/test_querier.py
  Skipped project/static/project/images/bg-paper.png (merged same as existing)
  Skipped project/static/project/apps/scatter-plot/js/xcharts.custom.js (merged same as existing)
  Skipped edb/models.py (merged same as existing)
  CONFLICT (rename/rename): Rename "edb/migrations.broken/0006_auto__del_field_site_entity_id.py"->"edb/migrations/0012_lengthen_owner_type_and_rating_charfield.py" in branch "Temporary merge branch 1" rename "edb/migrations.broken/0006_auto__del_field_site_entity_id.py"->"edb/migrations/0005_change_site_id_to_site_entity_id.py" in "Temporary merge branch 2" (left unresolved)
  Skipped edb/migrations/0007_rvalue_changed_to_r_value.py (merged same as existing)
  Skipped edb/migrations/0004_regenerate_garbled_field_names_due_to_slashes_in_csv_header_strings.py (merged same as existing)
  Auto-merging BE/templates/base.html
BUG: There are unmerged index entries:
BUG: 1 edb/migrations.broken/0005_auto__add_field_site_id__chg_field_site_entity_id.py
fatal: Bug in merge-recursive.c
  • git reset --hard doesn't work (subsequent merges still fail).
  • Merging in either direction (master -> mybranch or mybranch -> weather) results in the same BUG.
  • the offending files don't exist in the working directory but a related empty directory in master (edb/migrations.broken/) was deleted in checkout of master with rm -f, and git committed (but obviously git recorded no changes in the index)fix
  • no joy with git update-index --force-remove --unmerged --really-refresh --again --remove
1

There are 1 best solutions below

0
On

hub (github client) alias or a .gitignore of the deleted path migrations.broken was probably the source of the git "bug".

alias git=git   # or `brew remove hub`
git rm -rf edb/migrations.broken
git commit -am 'delete non-existent path to update git index'
git push origin feature/edb
git pull origin master
git checkout master
git pull origin master
git rm -rf edb/migrations.broken
git commit -am 'delete non-existent path to update git index'
git push origin master
git checkout feature/edb
git merge master
git commit -am 'delete non-existent path to update git index'

Many of these commands (all of the rm -rf commands) will result in warnings about nothing done or nonexistent files. But somehow it worked to eliminate the BUG caused by a confused git index.