I had this error as well:
error: update_ref failed for ref 'refs/remotes/origin/fixing': cannot update the ref 'refs/remotes/origin/fixing': unable to create directory for '.git/logs/refs/remotes/origin/fixing': No such file or directory
during a migration from hg Mercurial to GitLab repo using fast-export
and when I then tried to git push -u origin --all
to end the migration to GitLab.
I followed the other answer that said that a file needs to be deleted and found the files with the chosen directory name in them by running:
grep -rnl -e "MY_DIR"
Outcome:
on hg side:
- ./.hg/cache/branch2-base
checked, deletion does not solve it
and git side:
./.git/config
gets filled while you push the repo to the branch. The entries only show what was merged, it is not the configuration file that made it do so. Deleting a file that only documents what has been done makes no sense. The reason must be found elsewhere.
./.git/hg2git-heads
checked, deletion does not solve it
hg / git
I also checked deleting both the file on hg side and the hg2git-heads
file on git side, it did not change the error.
After so many tries, I checked the repo on GitLab itself. And it turned out that everything was in there as needed. All branches are there, even though they are also in that error list at the end of the push
.
One can see that this error likely does not harm the git repository. And since it does not harm here, it might also not harm there, in your case, when you pull the repository. In other words: you may ignore this error.
git gc --prune=now
to clean up your local repo – Deleddagit fetch --prune
– Deleddarm .git/logs/refs/remotes/origin/xyz
– Deleddals -ld .git/logs/refs/remotes/origin
? – Cynara