GIT: `error: unable to find <commit>` and `fatal: object <commit> not found` on pull

纵然是瞬间 提交于 2019-12-21 06:29:06

问题


We have a repo in Bitbucket, which we use as a central repo:

  1. we update it via pull requests or directly by pushing changes, and
  2. we synchronize the last changes in remote servers by pulling from it.

This has been working like a charm for about a year, but now we are not able to pull changes from this repo to update a remote server:

$ git pull origin
remote: Total 0 (delta 0), reused 0 (delta 0)
error: unable to find a1354e341c6773997c31a109e615d1bf9acb0119
fatal: object a1354e341c6773997c31a109e615d1bf9acb0119 not found

Nonetheless, this object/commit is available from Bitbucket and also in my local machine (where I generated it and then pushed to the central repo).

I have been dealing with this issue for more than 8 hours. My knowledge of Git is barely enough to do basic things so I tried blindly a lot of possible solutions that worked for other people in the same situation that I found on the Web, but none of them has produced results. I tried things like:

$ git gc
$ git fsck --full
$ git reflog expire --expire=0 --all

I also reset to the previous state of the repo and re-apply the changes again but it didn't work either.

Any clue on this subjet?

EDIT:

Jonathan Swinney asked me what happens when I try to clone the repo. Well, it is kinda weird. If I clone it in my local machine it works OK but it won't work on a remote server via SSH:

$ git clone https://******@bitbucket.org/******/******.git
Initialized empty Git repository in /root/a/idpro/.git/
Password: 
remote: Counting objects: 19853, done.
remote: Compressing objects: 100% (7525/7525), done.
remote: Total 19853 (delta 12910), reused 15843 (delta 10336)
Receiving objects: 100% (19853/19853), 21.12 MiB | 6.00 MiB/s, done.
Resolving deltas: 100% (12910/12910), done.
error: refs/remotes/origin/master does not point to a valid object!
error: Trying to write ref refs/heads/master with nonexistant object c16203dc93b1557fc1d01102ea460663a8112e50
fatal: Cannot update the ref 'HEAD'.

You can notice that c16203dc93b1557fc1d01102ea460663a8112e50 is not the same head as above (a1354e341c6773997c31a109e615d1bf9acb0119) since I pulled from another local repo and pushed the changes to the central one as part of my attempts to solve the problem.


回答1:


It turned out to be a versioning problem. Once we updated our GIT versions it worked just right.




回答2:


sudo yum upgrade –skip-broken –y git

Then again do git –version and it should tell you something > 1.8

Then try the git pull origin .



来源:https://stackoverflow.com/questions/28197242/git-error-unable-to-find-commit-and-fatal-object-commit-not-found-on

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!