查找未合并到特定本地分支(develop)的本地分支是通过执行
awk
但是我怎样才能找到没有合并到特定远程分支中的远程分支呢?目的是将那些未合并的分支留在本地,同时远程删除它们。
答案 0 :(得分:1)
要列出远程分支,请使用 -r
标志,以使用适当的远程名称引用远程分支前缀:
git branch -r --no-merged origin/develop
^^ ^^^^^^^
隐藏在 git branch 的帮助中的是它的描述:
$ git branch --help
NAME
git-branch - List, create, or delete branches
SYNOPSIS
git branch [--color[=<when>] | --no-color] [--show-current]
[-v [--abbrev=<length> | --no-abbrev]]
[--column[=<options>] | --no-column] [--sort=<key>]
[(--merged | --no-merged) [<commit>]]
[--contains [<commit]] [--no-contains [<commit>]]
[--points-at <object>] [--format=<format>]
[(-r | --remotes) | (-a | --all)] # <----
[--list] [<pattern>...]
git branch [--track | --no-track] [-f] <branchname> [<start-point>]
git branch (--set-upstream-to=<upstream> | -u <upstream>) [<branchname>]
git branch --unset-upstream [<branchname>]
git branch (-m | -M) [<oldbranch>] <newbranch>
git branch (-c | -C) [<oldbranch>] <newbranch>
git branch (-d | -D) [-r] <branchname>...
git branch --edit-description [<branchname>]
DESCRIPTION
...
-r, --remotes
List or delete (if used with -d) the remote-tracking branches.
Combine with --list to match the optional pattern(s).
...
答案 1 :(得分:0)
尝试使用 -a
标志来查看本地和远程分支:
尝试使用 -r
标志仅查看远程分支(如@phd 在评论中的建议)
像这样:
git branch -a --no-merged origin/master
或者查看仅远程分支:
git branch -r --no-merged origin/master