Git unable to resolve reference ‘refs/remotes/origin/HEAD‘: reference broken 的解决方法

pull 会报错

error: could not delete reference refs/remotes/origin/HEAD: cannot lock ref 'refs/remotes/origin/HEAD': unable to resolve reference 'refs/remotes/origin/HEAD': reference broken

于是尝试一些解决方法

回收垃圾没有效果

> git gc --prune=now
error: bad ref for .git/logs/refs/remotes/origin/HEAD
fatal: bad object refs/remotes/origin/HEAD
fatal: failed to run repack

清除本地仓库中不存在的引用,也没有效果

> git fetch --prune   
error: could not delete reference refs/remotes/origin/HEAD: cannot lock ref 'refs/remotes/origin/HEAD': unable to resolve reference 'refs/remotes/origin/HEAD': reference broken
From https://github.com/<my repo dir>
 - [deleted]         (none)     -> origin/HEAD
remote: Enumerating objects: 20, done.
remote: Counting objects: 100% (20/20), done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 11 (delta 7), reused 11 (delta 7), pack-reused 0 (from 0)
Unpacking objects: 100% (11/11), 9.06 KiB | 2.26 MiB/s, done.
fatal: bad object refs/remotes/origin/HEAD
error: https://github.com/<my repo dir>.git did not send all necessary objects

设置远程仓库的默认分支到本地仓库

> git remote set-head origin -a
origin/HEAD set to main

这个就解决了问题

Started by user admin Running as SYSTEM Building in workspace /var/jenkins_home/workspace/SGLD_SHIP_SYSTEM The recommended git tool is: NONE using credential 3daf7d0b-8918-4f92-9c5d-a3059a66a722 > git rev-parse --resolve-git-dir /var/jenkins_home/workspace/SGLD_SHIP_SYSTEM/.git # timeout=10 Fetching changes from the remote Git repository > git config remote.origin.url http://139.199.13.25:3000/shaofq/AG-SGLD-ILOG-1.0.git # timeout=10 Fetching upstream changes from http://139.199.13.25:3000/shaofq/AG-SGLD-ILOG-1.0.git > git --version # timeout=10 > git --version # 'git version 2.30.2' using GIT_ASKPASS to set credentials > git fetch --tags --force --progress -- http://139.199.13.25:3000/shaofq/AG-SGLD-ILOG-1.0.git +refs/heads/*:refs/remotes/origin/* # timeout=10 > git rev-parse refs/remotes/origin/master^{commit} # timeout=10 Checking out Revision 68b36471d8d68c7d5f6af47cd1c1025861e4cb03 (refs/remotes/origin/master) > git config core.sparsecheckout # timeout=10 > git checkout -f 68b36471d8d68c7d5f6af47cd1c1025861e4cb03 # timeout=10 Commit message: "feat:新增航线中文名维护" > git rev-list --no-walk 68b36471d8d68c7d5f6af47cd1c1025861e4cb03 # timeout=10 using settings config with name MySettings Replacing all maven server entries not found in credentials list is true [SGLD_SHIP_SYSTEM] $ /var/jenkins_home/tools/hudson.tasks.Maven_MavenInstallation/mymaven/bin/mvn -s /tmp/settings10948644921560376548.xml clean package -Pprod -Dmaven.test.skip=true -e Build step 'Invoke top-level Maven targets' marked build as failure Finished: FAILURE
06-07
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值