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
Asked Answered
D

3

10

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.

Delaunay answered 22/10, 2020 at 13:12 Comment(7)
You can try git gc --prune=now to clean up your local repoDeledda
If that doesn't work, you can also try to clean the remote with git fetch --pruneDeledda
If that still doesn't work you can try rm .git/logs/refs/remotes/origin/xyzDeledda
@Deledda I already tried prune and rm approaches but its still same.Delaunay
If pruning and deleting potentially bad ref doesn't work, we need more info on your situation to know what else could be causing thisDeledda
@Deledda I don't see any major check-ins in the branch which is causing this issue but investigating in parallel and let you know if found.Delaunay
"... nor such directory exists" I do not understand what you mean with this sentence : can you explain in more details ? What is the output of ls -ld .git/logs/refs/remotes/origin ?Cynara
R
5

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.

Raffish answered 5/8, 2021 at 10:19 Comment(1)
For me I thought I didn't have this issue but I was looking in .git/refs instead of .git/logs/refs which is where the error actually says it has trouble making a folderGratin
S
1

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
Seemly answered 8/2, 2023 at 1:35 Comment(0)
F
0

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.

Fideism answered 28/3, 2022 at 20:16 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.