Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/github/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
github:如何列出所有远程和本地分支,但没有用于拉取请求的分支?_Git_Github - Fatal编程技术网

github:如何列出所有远程和本地分支,但没有用于拉取请求的分支?

github:如何列出所有远程和本地分支,但没有用于拉取请求的分支?,git,github,Git,Github,现在GitHub将为每个pr创建一个隐藏分支,如/pr/1,当本地克隆上的“git branch-a”出现时可以看到,但在GitHub UI中隐藏 我仍然想保留这些分支,但我不想在shell上“git branch-a”时看到它们(只是太多了)。有人知道怎么做吗?您可以使用git branch--list pattern指定一个模式。模式使用unixshellglobbing 也就是说,为了避免列出分支,如pr/*,如pr/1,pr/2,请使用以下命令 git branch -a --list

现在GitHub将为每个pr创建一个隐藏分支,如/pr/1,当本地克隆上的“git branch-a”出现时可以看到,但在GitHub UI中隐藏


我仍然想保留这些分支,但我不想在shell上“git branch-a”时看到它们(只是太多了)。有人知道怎么做吗?

您可以使用
git branch--list pattern
指定一个模式。
模式使用unixshellglobbing

也就是说,为了避免列出分支,如
pr/*
,如
pr/1
pr/2
,请使用以下命令

git branch -a --list {'[!p]*','p[!r]*','pr[!/]*'}
或者您可以使用
grep
过滤结果,以避免复杂的模式

git branch -a | grep -v 'pr/*'

git branch--list
支持通配符,但可能不像bash中的extglob,因此我想您需要一个使用grep别名的shell。是的,grep永远是您的朋友。:)