5

管理Git在本地的远程分支追踪

 2 years ago
source link: https://jasonkayzk.github.io/2022/05/11/%E7%AE%A1%E7%90%86Git%E5%9C%A8%E6%9C%AC%E5%9C%B0%E7%9A%84%E8%BF%9C%E7%A8%8B%E5%88%86%E6%94%AF%E8%BF%BD%E8%B8%AA/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

如果远程的分支删除,本地会存在一个追踪的远程已经不存在的一个分支origin/xxx;

如果这种分支太多,本地的分支看起来会特别乱;

本文讲解了如何管理Git在本地的远程分支追踪;

管理Git在本地的远程分支追踪

下面的这个命令:

git remote prune

可以删除本地版本库上那些失效的远程追踪分支,具体用法是:

假如你的远程版本库名是 origin,则使用如下命令先查看哪些分支需要清理:

git remote prune origin --dry-run

随后执行:

git remote prune origin

这样,就完成了无效的远程追踪分支的清理工作;

需要注意,这里远程追踪分支是位于 .git/refs/remote/origin 下的分支;

如果有本地分支作为下游存在的话,还需要手动清理:

  git branch -d xxx

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK