列出 Git 远程中的所有活动分支
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/29673655/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
List all the active branches in Git remote
提问by zen
I am looking for a way to list all the active branches that are available on remote git repository. I tried:
我正在寻找一种方法来列出远程 git 存储库上可用的所有活动分支。我试过:
git branch -r
But this listed the already deleted branches as well. I do not want the list to display deleted branches.
但这也列出了已经删除的分支。我不希望列表显示已删除的分支。
回答by VonC
You can try (using git ls-remote
):
您可以尝试(使用git ls-remote
):
git ls-remote --heads origin
That would list the branches directly from the remote repo. No fetch necessary.
这将直接从远程仓库列出分支。无需提取。
回答by JC Teo
If someone arrives here looking for 'active branches' as branches that have not been merged in remote:
如果有人到达这里寻找“活动分支”作为尚未在远程合并的分支:
git branch -r --no-merged
回答by peresleguine
Try git remote show origin
(or any other remote repository). Use git remote prune origin
to get rid of deleted branches.
尝试git remote show origin
(或任何其他远程存储库)。用于git remote prune origin
删除已删除的分支。
回答by Massive
If you have a main directory(parent) not in git And multiple sub directories that are in git The git cmd line will not work from the parent dir. But this will. Listing all the sub directories and their active branches.
如果您的主目录(父目录)不在 git 中,并且有多个子目录在 git 中,则 git cmd 行将无法从父目录运行。但这会。列出所有子目录及其活动分支。
Run from parent dir.
for i in ls -l | grep ^d|cut -d':' -f2|cut -d ' ' -f2
; do cd $i ;echo $i ;git branch; cd ..; done
从父目录运行。因为我在ls -l | grep ^d|cut -d':' -f2|cut -d ' ' -f2
;做 cd $i ;echo $i ;git branch; 光盘..; 完毕