git 删除远程分支,本地依然有记录

git 删除远程分支,本地依然有记录

在远程仓库删除dev分支后,本地git branch -a依然能查看到记录。

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

方式一

使用git fetch --prune命令。

$ git fetch --prune
 - [deleted]         (none)     -> origin/dev

再次使用git branch -a查看,已没有被删除分支记录。

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

方式二

使用git remote show origin命令查看远程与本地对应信息。

$ git remote show origin
* remote origin
  Fetch URL: https://gitee.com/xxx/xxx.git
  Push  URL: https://gitee.com/xxx/xxx.git
  HEAD branch: master
  Remote branches:
    master                  tracked
    refs/remotes/origin/dev stale (use 'git remote prune' to remove)
    release                 tracked
  Local branches configured for 'git pull':
    master  merges with remote master
    release merges with remote release
  Local refs configured for 'git push':
    master  pushes to master  (up to date)
    release pushes to release (up to date)

根据提示使用git remote prune origin命令。

$ git remote prune origin
Pruning origin
URL: https://gitee.com/xxx/xxx.git
 * [pruned] origin/devb

再次使用git branch -a查看,已没有被删除分支记录。

$ git branch -a
* master
  release
  remotes/origin/HEAD -> origin/master
  remotes/origin/master
  remotes/origin/release
posted @ 2022-05-04 14:40  梦渊同学  阅读(1157)  评论(0编辑  收藏  举报