找到本地分支,这些分支没有合并到特定的本地分支(develop),可以通过以下步骤实现:
但是我如何找到未合并到特定远程分支的远程分支呢?目的是在本地保留这些未合并的分支,同时将它们从远程删除。
git branch --no-merged develop
但是我如何找到未合并到特定远程分支的远程分支呢?目的是在本地保留这些未合并的分支,同时将它们从远程删除。
要列出远程分支,请使用-r
标志,并使用适当的远程名称引用远程分支前缀:
git branch -r --no-merged origin/develop
^^ ^^^^^^^
$ 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).
...
-a
标志来查看本地和远程分支:
尝试使用-r
标志仅查看远程分支(根据@phd在评论中的建议)。git branch -a --no-merged origin/master
或者只查看远程分支:
git branch -r --no-merged origin/master
git fetch
或git remote update
命令,也许还可以加上--prune
选项,以便更新本地Git对远程Git的分支名称和哈希ID的副本。 - undefinedgit fetch --prune
命令。 - undefined