Hi,
I would like to expose a Git / Gitlab problem preventing me from initializing a remote with gitlab-ee-14.2.4. This is my goal:
- I need to work on a small part of a very large project with a very long history (several GB) and I want to downsize it but keeping tho possibility to push or pull some commits with may be cherry-pick.
- I create a branch, remove all the needless parts, commit and push this branch on the remote
- Then I clone this branch in a new folder, truncating the history with:
git clone -b mybranch --single-branch --depth=1 git@my-global-remote:myrepo myNewrepo
- As I have no master (called main with new version of gitlab) I create a main branch:
git checkout -b main
- That’s fine, I’ve only some hundreds of MB with a common commit in the main branch. So I create a new empty repo on my local gitlab instance and I add this local gitlab remote to push :
git remote add mostgit git@my.local.repo:begou/my-test.git
as suggested in the web interface after creating an empty repo.
But I cannot push my repo to my local gitlab instance:
git push mostgit main
Counting objects: 4768, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (2764/2764), done.
Writing objects: 100% (4768/4768), 372.45 MiB | 10.58 MiB/s, done.
Total 4768 (delta 1889), reused 4768 (delta 1889)
remote: Resolving deltas: 100% (1889/1889), done.
remote: fatal: did not receive expected object b8a07923a333c969deb3480a6c356300c5c195c9
error: unpack failed: index-pack abnormal exit
To git@my.local.repo:begou/my-test.git
! [remote rejected] main -> main (unpacker error)
error: failed to push some refs to 'git@my.local.repo:begou/my-test.git'
I’m sure I’m wrong somewhere but… where ?
Thanks
Patrick
Hi,
maybe the local repository is corrupted, I’d suggest running git gc
and git fsck
to analyze and fix.
my.local.repo
as GitLab server has logs, can you look into them and see if that gives more insights into the remote
error?
Cheers,
Michael
Hi Michael,
I’m not a “git gourou” and I’ve spent all these last hours readings many docs but, if I have well understood them, this is a shallow clone and documenttaion says it is not possible to push a shallow clone. So may be there is something more to do before the push to the gitlab empty remote project.
The git gc
and git fsck
commands ran successfuly but do not allow the push on an empty remote.
Hi,
Thanks, now we can rule out that there’s a local problem with the repository integrity.
Thanks for bringing this to my attention, I did not see that from the --depth=1
command. I never worked with shallow clones myself, so let’s dig in there together.
Searching for push a shallow clone
brings up this SO topic, which says to run
git fetch --unshallow
to fetch all branches, and allow the push again. Docs for fetch say the following:
–unshallow
If the source repository is complete, convert a shallow repository to a complete one, removing all the limitations imposed by shallow repositories.
If the source repository is shallow, fetch as much as possible so that the current repository has the same history as the source repository.
Does this help to being able to push afterwards?
Kind regards,
Michael
Hi Michael,
using git fetch --unshallow
unfortunatly resets the shallow clone re-adding all the history and i’m back with many gigabytes of datas and the full history.
Not sure Git can do what I would like to do, working with a local remote knowing just a limited part of the full project
Many thanks for your trying to find a solution.
Patrick
1 Like
I would say to check if your new repo is really empty, and try push in force mode. But this error make me think that it is not the case here.
error: unpack failed: index-pack abnormal exit
I suggest raising an issue at GitLab.org / gitaly · GitLab for a better error message that would say that shallow clones are not supported with a link to explanation why.
1 Like
Guys, looks like it is related to space issue on the server - wherever the git is running on