如何在执行git fetch --all时忽略一些复制到本地git的分支/标签 [英] How to ignore some branches/tags being copied to local git when do git fetch --all

查看:792
本文介绍了如何在执行git fetch --all时忽略一些复制到本地git的分支/标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在git中添加了许多遥控器.每个远程站点都是一个开发人员的存储库.每天我fetch --all看到他们创建的任何新分支都准备好进行审查.

I have many remotes added to my git. Each remote is a repository for one developer. Every day I fetch --all to see any new branches they create that are ready to review.

但是,开发人员可以将私有"分支推送到远程.假设所有带下划线前缀的分支都尚未准备好进行审核,而其他分支已准备好进行审核.

However, developers can push "private" branches to the remote. Say, all branches named with a underscore prefix are not ready to review, while other branches are ready to review.

在执行git fetch --all时,我的git图(按/libexec/git-core/git-gui)将看到所有分支,无论它们是否具有下划线前缀.它使图复杂化.

When doing the git fetch --all, my git graph (by /libexec/git-core/git-gui) will see all branches no matter whether they have the underscore prefix or not. It complicates the graph.

我希望git fetch忽略那些_XXXX分支,将其下载到我的本地git中.因此,当我查看git图时,就像:

I want git fetch to ignore those _XXXX branches from being downloaded to my local git. So when I view the git graph it's like:

  • 显示分支: RemoteA/Branch1RemoteB/Branch1RemoteB/Branch2
  • 忽略分支:RemoteA/_Branch2RemoteB/_Branch3
  • Shows branches: RemoteA/Branch1 , RemoteB/Branch1, RemoteB/Branch2
  • Ignores branches: RemoteA/_Branch2, RemoteB/_Branch3

我该怎么做?

推荐答案

您可以使用命名空间,而不是使用'_'命名约定,将分支推入origin/review/Branch1(git push Branch1:review/Branch1)
(在该答案中命名为组" ,或在

Instead of using a '_' naming convention, you could use namespaces, pushing the branch in origin/review/Branch1 (git push Branch1:review/Branch1)
(named "group" in that answer, or "hierarchical branch name (branch names with slash) in that answer)

这样,您只需获取评论"命名空间中的内容:

That way, you only have to fetch what is in the "review' namespace:

git fetch +refs/heads/review/*:refs/remotes/origin/review/*


唯一的其他选择是脚本,该脚本将:


The only other option would be a script, which would:

这篇关于如何在执行git fetch --all时忽略一些复制到本地git的分支/标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆