I am facing below issue while taking fresh pull. (git pull)

error: cannot update the ref 'refs/remotes/origin/xyz': unable to create directory for '.git/logs/refs/remotes/origin/xyz': No such file or directory

I have checked particular location and there is neither permission issue nor such directory exists.

Jfyi I have already searched similar threads but those are not worked for me and most of them are related to append, delete etc.

I am badly stuck at this and any help would be highly appreciated.

3

There are 3 answers

0
questionto42 On

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.

0
Jason Wong On

For my case, it was a mixed of using non-root and root account when cloning and pushing git from the directory. So what I did
Just run these - I am using student ID

  1. cd; sudo chown -R student:student .git
  2. mkdir -p .git/logs/refs/remotes/origin/main
  3. git push -u origin --force
    Hope this help
0
Boris On

I had the same issue and found that there is a file with the name of directory to be created. I deleted the file and this resolved the issue.