I get an error when I try to push a bit repo to a new server:
$ git push -f research master
Enumerating objects: 13060, done.
Counting objects: 100% (13060/13060), done.
Delta compression using up to 4 threads
Compressing objects: 100% (3397/3397), done.
Writing objects: 100% (13060/13060), 5.59 MiB | 364.00 KiB/s, done.
Total 13060 (delta 9516), reused 13060 (delta 9516)
remote: Resolving deltas: 100% (9516/9516), done.
remote: error: bad config line 14 in blob .gitmodules
remote: error: object 4f098d01fb9671a7f5ff5f617ef89b289a8ea9bb: gitmodulesParse: could not parse gitmodules blob
remote: fatal: fsck error in pack objects
error: remote unpack failed: index-pack abnormal exit
To gitlab.research.com:proj/repo.git
! [remote rejected] master -> master (unpacker error)
error: failed to push some refs to 'git@gitlab.research.com:proj/repo.git'
$
Strangely, I get the same error when I run git fsck
locally:
$ git fsck
Checking object directories: 100% (256/256), done.
warning in blob 4f098d01fb9671a7f5ff5f617ef89b289a8ea9bb: gitmodulesParse: could not parse gitmodules blob
Checking objects: 100% (13060/13060), done.
$
It turns out that "line 14" in the .gitmodules
file is not in the current version of the file, which is only 11 lines long. The problem results because there was a version of .gitmodules
that was committed which had a conflict.
Can I just delete the blob and push it to the new repo, or is there a deep problem that I cannot easily fix?
EDIT - NEW INFORMATION!
Given @torek's excellent posting below, combined with the script in Which commit has this blob? (the first script worked, but the second one did not), I was able to find the problematic commit:
$ ~/.bin/git-find-object 4f098d01fb9671a7f5ff5f617ef89b289a8ea9bb
06407fd merged changes from master and stats
My git repo only has one branch visible:
$ git branch -v
* master e8ff018 minor
I can check out the problematic commit:
$ git checkout 06407fd
Checking out files: 100% (321/321), done.
fatal: bad config line 14 in file /home/xv32/gits/repo/.gitmodules
$
I edited the .gitmodules
file directly, and removed the offending lines:
<<<<<<< HEAD
branch = ee
=======
>>>>>>> master
I did an git add .gitmodules
I did a:
$ git commit --amend -m 'fixed conflict in .gitmodules'
OMG it changed a lot of stuff.
I then did a git status:
$ git status
On branch master
Your branch and 'origin/master' have diverged,
and have 1 and 1 different commits each, respectively.
(use "git pull" to merge the remote branch into yours)
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: submodule1 (new commits)
modified: submodule2 (new commits)
modified: submodule3(new commits)
no changes added to commit (use "git add" and/or "git commit -a")
$
git fsck no longer reports problems:
$ git fsck
Checking object directories: 100% (256/256), done.
Checking objects: 100% (15206/15206), done.
But I am still unable to push to the remote repo:
$ git push -f research master
Counting objects: 13245, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (3395/3395), done.
Writing objects: 100% (13245/13245), 5.68 MiB | 2.81 MiB/s, done.
Total 13245 (delta 9746), reused 13180 (delta 9702)
remote: error: bad config line 14 in blob .gitmodules
remote: error: object 4f098d01fb9671a7f5ff5f617ef89b289a8ea9bb: gitmodulesParse: could not parse gitmodules blob
remote: fatal: fsck error in packed object
error: remote unpack failed: index-pack abnormal exit
To https://gitlab.research.com/repo/repo.git
! [remote rejected] master -> master (unpacker error)
error: failed to push some refs to 'https://gitlab.research.com/censyn-sensitive/das_decennial.git'
$
Also, when I do the git --amend
, a whole bunch of important things disappear, beyond the bad lines in the object.
Honestly, I do not understand why I am even getting an error, since the error is not at the top of the tree.