Subtree-split with empty-ident commit; or, deleting a commit without rebase: an unusual use-case

445 Views Asked by At

I have a very large repository with one branch. Its working tree is constantly being updated (every few seconds) and committed (every few minutes).

My actual goal here is to run git subtree split for a particular directory and truncate most of the repository after moving that directory to a save location. (See Detach (move) subdirectory into separate Git repository) However, this fails because one of the commits has an empty ident.

So, I proceeded to try to remove this commit. But the only way to do this that I've found so far is rebase. However, not only would this take forever on my repository, but I would need to stop the constant updates to the working tree during the process, which may not be possible or ideal.

Given (my understanding of) the way that commits are represented internally, I would think it would be a simple matter to just eliminate the commit from history and switch the links of the neighboring commits. Though, I would imagine it should be even easier to get subtree split to work with a commit that has an empty ident..

EDIT

OK, I've recently realized that I can use git replace --edit <ref> to change the ident on the relevant commit. However, I've also realized that the past 1000 commits have empty idents. Should I write a script to change them all, or can subtree split just work around this?

EDIT

Okay, so I've managed to change all of the author/committer names and emails using filter-branch --env-filter, and then created a graft and successfully cut off the old commits as described in the linked question. However, my repository is still the same size -- how do I delete the extra space taken up by the old commits?

EDIT

I've tried several methods found on SO and elsewhere.

  • git gc --aggressive --prune=now fails with
error: Could not read 2cbe0846930116a0eff259abbf2caab74737b379                                                
fatal: Failed to traverse parents of commit cc7349dcde96404a767afaf07da3186c7f31e540                            
error: failed to run repack
  • git prune is successful, but does not reduce the size of the repository much. (230G to about 205G)
  • git update-ref -d on the two hashes in the above error does not fix the issue
  • With respect to the branch I want to preserve, I cannot bundle or pull from elsewhere because of memory constraints. Otherwise, I'd just do that and delete this repository.
  • git fsck yields the following:
error in commit c9ce63c35025b0cc7396144f4f070b9b0f56fb19: invalid author/committer line - missing space before email
Checking object directories: 100% (256/256), done.
Checking objects: 100% (11760/11760), done.
Checking connectivity: 163203, done.
dangling commit 6b3b3062c0df601c8e186400d7a8fc1bf67d28b9
dangling commit a451609287a38162c70f42aeab8a0a84bb2d72dd
dangling commit 13bdd914dcf58dfd6565415884d03b6d8a69b6d5
dangling commit d8137a92199ca75bb6098d28f20a6f52dfb33b7b
dangling commit 6ca49a78de5fb4dd381c210e28c23e5600470042
dangling commit 703c6b102f9398897db6b82a0eea57440f979e1f
dangling commit 0f15744cc9dd1751dc38d3045113cf53c9936058
dangling commit 2e209c2f159766adf143d0b9a50717977d20df3f
dangling commit 6b8d3538efa1b5714f33ee95a5aa953dfd0a7b0a
dangling commit 9cdcc59c28d4b60ed82dd20eae1466e959f9aaac
dangling commit 41f68584ab5c5bc8e97dd1951fff8465d5b3c46c
dangling commit d30be628e980388a653672cc6fed916d55a4d954
dangling commit a4b2dee6464c245fe2b1d22dd51e5da92bd395dd
dangling commit 5a0b5f30eabe447ed5c7b29685145c716be79d97
dangling commit 401daf96420733905dd281cca3b127f11924d97b
dangling commit c184571e9bdb0792143a2fa976c966fc60e92280

Basically, I need a way to truncate whatever is leftover from the commits I destroyed with graft and filter-branch. Really, my priority is just to keep the aforementioned other branch AND the working directory intact. I'm OK with destroying everything else if that is necessary.

0

There are 0 best solutions below