问题:我想要一种删除所有没有远程的本地分支的方法。将分支机构的名称输入到git branch -D {branch_name}
很容易,但我怎么首先获取该列表?列出所有没有远程的本地分支
例如:
我创建一个没有遥控器一个新的分支:
$ git co -b no_upstream
我列出我的所有分支,只有有1与远程
$ git branch -a
master
* no_upstream
remotes/origin/HEAD -> origin/master
remotes/origin/master
什么命令我运行得到no_upstream
作为答案?
我可以运行git rev-parse --abbrev-ref --symbolic-full-name @{u}
,这将表明它没有遥控:
$ git rev-parse --abbrev-ref --symbolic-full-name @{u}
error: No upstream configured for branch 'no_upstream'
error: No upstream configured for branch 'no_upstream'
fatal: ambiguous argument '@{u}': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
但因为这是一个错误,它不会让我使用它或管道给其他命令。我打算使用这个作为shell脚本别名git-delete-unbranched
或可能使一个超级简单的宝石像git-branch-delete-orphans
任何帮助,将不胜感激!谢谢
另请参阅http://stackoverflow.com/questions/4950725/how-do-i-get-git-to-show-me-which-branches-are-tracking-what – 2014-03-17 16:25:33
[删除本地分支机构不再在远程](http://stackoverflow.com/questions/7726949/remove-local-branches-no-longer-on-remote) – ks1322 2016-06-07 15:37:35