push到远程仓库时出现master → Empty repository bad revision ‘refs/remotes/gitle/master..refs/heads/master‘

本文介绍了当Git推送遇到refs/remotes错误时,通过清理本地引用、拉取远程代码并设置分支跟踪的详细步骤,以解决无法推送的问题。
摘要由CSDN通过智能技术生成

1.问题描述:

2.目标描述:

3.解决办法:

    这个问题可能是由于Git的引用(refs)或分支信息出现了错误或冲突,导致无法推送。
以下是解决这个问题的步骤:
  1. 首先,进入项目的 `.git` 目录,这个目录通常位于项目的根目录下。你也可以使用命令行工具(如bash、cmd或PowerShell)来操作。

cd 项目名/.git/refs/remotes/origin

 rm *


  2. 在 `.git` 目录下,找到 `refs/remotes/origin(或其他名字,如果这里不是origin则下面涉及到origin的都要改成自己的文件名)` 文件夹,删除其中的所有文件。这些文件代表了你的本地仓库对远程仓库的引用。

cd 项目名

git pull origin master


  3. 返回到项目的根目录,然后执行 `git pull` 命令。这个命令会从远程仓库拉取最新的代码,并重新创建刚才删除的远程引用。

git pull origin master


  4. 最后,设置本地的 `master` 分支跟踪远程的 `master` 分支。这可以通过 `git branch --set-upstream-to=origin/master master` 命令完成。
   

git branch --set-upstream-to=origin/master master

5.重新再idea上进行push,就可以看到不是master → Empty repository bad revision 'refs/remotes/gitle/master..refs/heads/master'这一串了,还可以点击push按钮了,到此为止,问题应该就解决了。如果问题依然存在,可能需要更深入地检查你的Git配置和项目状态,

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、付费专栏及课程。

余额充值