美文网首页Git使用Git
git loose object问题处理

git loose object问题处理

作者: EldonZhao | 来源:发表于2017-01-23 10:26 被阅读346次

问题现象:

eldon@ubuntu:~/github/ColusLifeDemo$ git show
error: object file .git/objects/48/fafe9a709ab087741eb9a9824f457b89a4b27d is empty
error: object file .git/objects/48/fafe9a709ab087741eb9a9824f457b89a4b27d is empty
fatal: loose object 48fafe9a709ab087741eb9a9824f457b89a4b27d (stored in .git/objects/48/fafe9a709ab087741eb9a9824f457b89a4b27d) is corrupt

前天本人虚拟机强制关机了,怀疑跟这个有关。

删除冲突的文件:

eldon@ubuntu:~/github/ColusLifeDemo$ rm .-rf .git/

初始化本地仓库:

eldon@ubuntu:~/github/ColusLifeDemo$ git init
Initialized empty Git repository in /home/eldon/github/ColusLifeDemo/.git/

添加远端仓库:

eldon@ubuntu:~/github/ColusLifeDemo$ git remote add origin https://EldonZhao:xyz198920@github.com/ColusLife/ColusLifeDemo.git

同步代码:

eldon@ubuntu:~/github/ColusLifeDemo$ git fetch
remote: Counting objects: 197, done.
remote: Compressing objects: 100% (11/11), done.
remote: Total 197 (delta 0), reused 0 (delta 0), pack-reused 186
Receiving objects: 100% (197/197), 50.69 KiB | 24.00 KiB/s, done.
Resolving deltas: 100% (80/80), done.
From https://github.com/ColusLife/ColusLifeDemo
 * [new branch]      master     -> origin/master

分支设置:

eldon@ubuntu:~/github/ColusLifeDemo$ git reset --hard origin/master
HEAD is now at 48fafe9 Change code to support admin to manage models
eldon@ubuntu:~/github/ColusLifeDemo$ git branch --set-upstream-to=origin/master master
Branch master set up to track remote branch master from origin.
eldon@ubuntu:~/github/ColusLifeDemo$ git branch -a
* master
  remotes/origin/master

参考资料:

相关文章

网友评论

    本文标题:git loose object问题处理

    本文链接:https://www.haomeiwen.com/subject/yghabttx.html