Skip to content

快速更新远程分支

  1. 清除旧分支

有时候需要让vscode或者是其他的ide显示最新的远程分支。如下图,下面有很多分支是过期的,如各种bug开头的分支。

image-20220925204624533v

  1. 全量更新本地的旧分支和提交内容

比如说家用电脑进入到一个长期未更新的项目,就可以用该命令快速全量更新了。

具体做法

查找资料得知,需要使用命令行

bash
git remote update origin --prune

如下图,删除了很多无用的旧分支:

image-20220925204706126

最终可用的远程分支全部更新为最新分支,如下图:

image-20220925204724414

参考资料

其他相似内容

Git Prune、Git Fetch --prune 和 Git Remote Prune 之间有什么区别?

在学习了解本地清除缓存,分支更新等内容时,了解到了关于 prune 的内容。需要专门学习该命令的细节。

参考资料

https://www.atlassian.com/git/tutorials/git-prune

文章所述的最佳实践

拉取远程分支,并做剪枝。

bash
git fetch --prune

建议使用简写:

bash
git fetch -prune

有疑惑 关于 git remote 的命令?

TODO: 询问 chatGPT

这几个命令什么意思?

bash
git remote show origin
git remote prune origin
git remote update origin

git remote show origin

专用于 修剪和删除远程仓库中不可用的所有本地分支。

参考资料

https://www.delftstack.com/zh/howto/git/git-prune-local-branches/#在-git-中删除修剪本地分支

git remote prune origin

git remote update origin

贡献者

The avatar of contributor named as ruan-cat ruan-cat
The avatar of contributor named as 阮喵喵 阮喵喵

页面历史