【错误记录】Git 使用报错 ( git branch -a 仍能查询到已经删除的远程分支 )

简介: 【错误记录】Git 使用报错 ( git branch -a 仍能查询到已经删除的远程分支 )

文章目录

一、报错信息

二、解决方案





一、报错信息


之前已经执行


git push origin --delete feature1


命令 , 删除了 feature1 远程分支 , 删除操作成功 , 远程仓库中 , 只剩下 master 主分支 ;


远程仓库分支如下图 :



image.png

执行


git branch


进行本地版本库分支查询 , 本地只有 master 分支 ;


image.png

然后再执行


gir branch -a


查询远程分支 , 发现仍然能查询到 remotes/origin/feature1 远程分支 ;


D:\Git\git-learning-course>git branch -a
* master
  remotes/origin/HEAD -> origin/master
  remotes/origin/feature1
  remotes/origin/master


image.png


注意 , 此时再执行 git push origin --delete feature1 命令 , 是无用的 , 只会提示错误信息 ;






二、解决方案


执行


git remote show origin


命令 , 可以列出在本地分支中对应的远程分支 , 也就是本地分支执行 git push 命令 , 代码会被推送到哪个远程分支 ;


D:\Git\git-learning-course>git remote show origin
warning: redirecting to https://codechina.csdn.net/han12020121/git-learning-course.git/
* remote origin
  Fetch URL: https://codechina.csdn.net/han12020121/git-learning-course
  Push  URL: https://codechina.csdn.net/han12020121/git-learning-course
  HEAD branch: master
  Remote branches:
    master                       tracked
    refs/remotes/origin/feature1 stale (use 'git remote prune' to remove)
  Local branch configured for 'git pull':
    master merges with remote master
  Local ref configured for 'git push':
    master pushes to master (up to date)


image.pngimage.png

image.png


然后 , 执行


git remote prune origin


命令 , 可以同步本地远程分支 , 也就是删除 feature1 分支 ;


D:\Git\git-learning-course>git remote prune origin
warning: redirecting to https://codechina.csdn.net/han12020121/git-learning-course.git/
Pruning origin
URL: https://codechina.csdn.net/han12020121/git-learning-course
 * [pruned] origin/feature1


image.png


最后 , 再次执行


git branch -a


命令 , 查询远程分支 , 发现只剩下 master 主分支了 ;


D:\Git\git-learning-course>git branch -a
* master
  remotes/origin/HEAD -> origin/master
  remotes/origin/master


目录
相关文章
|
存储 安全 开发工具
深度解决 Git “fatal: refusing to merge unrelated histories” 错误解析什么是历史分支优雅草卓伊凡
深度解决 Git “fatal: refusing to merge unrelated histories” 错误解析什么是历史分支优雅草卓伊凡
1357 4
深度解决 Git “fatal: refusing to merge unrelated histories” 错误解析什么是历史分支优雅草卓伊凡
|
开发工具 git
图解Git——分支的新建与合并《Pro Git》
在Git开发中,新建与合并分支是常见的操作。以实际开发为例:为实现新需求创建分支`iss53`进行开发;遇紧急Bug时,切换至线上分支创建`hotfix`修复并合并回线上分支,再切换回`iss53`继续工作。完成`iss53`后,切换到`master`合并。若出现冲突,使用`git status`查看,手动编辑解决冲突后标记为已解决并提交。图形化工具如`git mergetool`也可辅助解决冲突。
598 9
|
开发工具 git 开发者
图解Git——分支简介《Pro Git》
Git 分支是其核心特性之一,允许开发者从主开发线分离工作,避免干扰主线。传统版本控制系统创建分支效率低,而Git的分支创建和切换非常轻量高效。
978 9
|
安全 开发工具 git
git添加远程仓库报错To add an exception for this directory解决方案-优雅草卓伊凡
git添加远程仓库报错To add an exception for this directory解决方案-优雅草卓伊凡
1013 5
git添加远程仓库报错To add an exception for this directory解决方案-优雅草卓伊凡
|
开发工具 git
Git版本控制工具合并分支merge命令操作流程
通过以上步聚焦于技术性和操作层面指南(guidance), 可以有效管理项目版本控制(version control), 并促进团队协作(collaboration).
3040 15
|
开发工具 git 开发者
vscode+git解决远程分支合并冲突
通过这些详细步骤,您可以掌握如何使用VSCode和Git高效地解决远程分支合并冲突,提高开发效率和代码质量。希望这些内容对您的学习和工作有所帮助。
3907 86
|
算法 安全 网络安全
git clone操作报错diffie-hellman-group1-sha1的解决方案
在处理这一问题时,需要确保了解相关操作的安全影响。`diffie-hellman-group1-sha1`算法被认为是不够安全的,这是因为随着计算能力的提高,`SHA-1`算法可以在合理的时间内被破解,而且其对应的 `1024位`Diffie-Hellman组也可能不够强大。因此,在确保Git操作的同时,也要考虑提升安全性的长期解决办法。强烈推荐与管理员或相关技术支持团队合作,升级和加强服务器端的安全配置。
437 12
|
开发工具 git 索引
warning: You ran ‘git add’ with neither ‘-A (—all)’ or ‘—ignore-removal’,报错如何解决 git报错 ‘git add —ignore-removal <pathspec>优雅草卓伊凡
warning: You ran ‘git add’ with neither ‘-A (—all)’ or ‘—ignore-removal’,报错如何解决 git报错 ‘git add —ignore-removal <pathspec>优雅草卓伊凡
393 21
warning: You ran ‘git add’ with neither ‘-A (—all)’ or ‘—ignore-removal’,报错如何解决 git报错 ‘git add —ignore-removal <pathspec>优雅草卓伊凡
|
Shell 开发工具 git
解决git bash报错:在仓库中检测到可疑的所有权
总的来说,解决“在仓库中检测到可疑的所有权”的报错,关键在于理解和调整文件或目录的所有权。只要我们正确地设置了文件或目录的所有权,那么我们就可以避免这种问题,让Git Bash正常工作。
934 22
|
网络协议 开发工具 git
解决 git 报错 “fatal: unable to access ‘https://github.com/.../.git‘: Recv failure Connection was rese
在使用 Git/Git小乌龟 进行代码管理的过程中,经常会遇到各种各样的问题,其中之一就是在执行 git clone 或 git pull 等操作时出现 “fatal: unable to access ‘https://github.com/…/.git’: Recv failure Connection was reset” 的报错。这个问题通常是由网络连接问题或代理设置不正确导致的。在我的个人使用经验中,我亲自尝试了四种方法,它们都能够有效地解决这个报错。个人比较推荐方法二。
10791 1