After having split the repository in my workspace into two by filtering, I cloned them "bare" into new origins, and then continued to work in a cloned workspace on the current branch without a problem.
Several commits later I merged my branch into master
, then pushed it successfully.
Next I deleted the obsolete branches in my workspace.
However when I tried to get rid of obsolete branches in the "origin" repository too, I have problems like these:
git branch
lists branches that I cannot delete usinggit branch -d
due tofatal: Couldn't look up commit object for HEAD
.git fsck
complains:notice: HEAD points to an unborn branch (bitmap-generic)
(I was hoping git fsck
would identify those "dead" branches and clean them up, but obviously it did not)
Unfortunately I did not record the exact commands, but roughly this is what I did (based on the instructions given in section 19.1 of the Git book by Preißel and Stachmann, 1st edition (German)):
Make a backup:
git clone --no-hardlinks --bare orig.git backup.git
Remove unwanted files:
git filter-branch --force --index-filter 'git rm --cached --ignore-unmatch ...' --tag-name-filter cat --prune-empty -- --all
Reorganize:
git clone --no-hardlinks --bare backup.git new.git
Drop backup:
rm -rf backup.git
Check out
new.git
and work on itRemove unneeded obsolete branches in
new.git
:git branch -d ...
How can I fix these issues? Git version being used is 2.26.2.