判断分支是否需要merge的方法

git --help branch

NAME
       git-branch - List, create, or delete branches

SYNOPSIS
       git branch [--color[=<when>] | --no-color] [-r | -a]
               [--list] [-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>] [<pattern>...]
       git branch [--track | --no-track] [-l] [-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>]
(其他信息大家可以 命令行运行查看,此处不再列出)           

可以判断的命令参数:

--contains [<commit>]
    Only list branches which contain the specified commit (HEAD if not specified). Implies --list.

--no-contains [<commit>]
    Only list branches which don’t contain the specified commit (HEAD if not specified). Implies --list.

--merged [<commit>]
    Only list branches whose tips are reachable from the specified commit (HEAD if not specified). Implies --list, incompatible with --no-merged.

--no-merged [<commit>]
    Only list branches whose tips are not reachable from the specified commit (HEAD if not specified). Implies --list, incompatible with --merged.

提醒:

NOTES
       If you are creating a branch that you want to checkout immediately, it is easier to use the git checkout command with its -b option to create a branch and check it out with
       a single command.

       The options --contains, --no-contains, --merged and --no-merged serve four related but different purposes:

       ·   --contains <commit> is used to find all branches which will need special attention if <commit> were to be rebased or amended, since those branches contain the specified
           <commit>.

       ·   --no-contains <commit> is the inverse of that, i.e. branches that don’t contain the specified <commit>.

       ·   --merged is used to find all branches which can be safely deleted, since those branches are fully contained by HEAD.

       ·   --no-merged is used to find branches which are candidates for merging into HEAD, since those branches are not fully contained by HEAD.

故而可以利用如上的命令来看看需不需要merge

git branch --contains origin/master
git branch --merged origin/master
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值