前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >解决git远程分支已经删除本地还存在的办法

解决git远程分支已经删除本地还存在的办法

作者头像
PHP学习网
发布2022-08-03 14:04:51
2.7K0
发布2022-08-03 14:04:51
举报
文章被收录于专栏:PHP学习网PHP学习网

最近因为公司项目的需要在研究学习git,碰到个问题,我将远程分支直接删除了,在本地并有删除于是我用 git branch -a 还可以可以看到远程存在此分支。

$ git branch -a master * test remotes/origin/HEAD -> origin/master remotes/origin/master remotes/origin/newcarapi-test remotes/origin/test

remotes/origin/newcarapi-test (其实是已经删除的,但是还是存在) 使用 git remote show origin 查看remote地址,远程分支,还有本地分支与之相对应关系等信息。

$ git remote show origin warning: redirecting to http://gitlab.xcar.com.cn/product_library/newcar-api.git/ * remote origin Fetch URL: http://gitlab.xcar.com.cn/product_library/newcar-api Push URL: http://gitlab.xcar.com.cn/product_library/newcar-api HEAD branch: master Remote branches: gao.feifei new (next fetch will store in remotes/origin) master tracked refs/remotes/origin/newcarapi-test stale (use 'git remote prune' to remove) test tracked Local branches configured for 'git pull': master merges with remote master test merges with remote test Local refs configured for 'git push': master pushes to master (fast-forwardable) test pushes to test (up to date)

根据提示我们可以看到远程的已经不存在了,并且让使用(use 'git remote prune' to remove)此命令 $ git remote prune origin warning: redirecting to http://gitlab.xcar.com.cn/product_library/newcar-api.git/ Pruning origin URL: http://gitlab.xcar.com.cn/product_library/newcar-api * [pruned] origin/newcarapi-test

执行完命令后在次用 git branch -a 查看,可以看到已经被删除 (git branch -r 只查看远程的分子)

$ git branch -a master * test remotes/origin/HEAD -> origin/master remotes/origin/master remotes/origin/test

本文参与 腾讯云自媒体同步曝光计划,分享自微信公众号。
原始发表:2017-03-30,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 PHP学习网 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档