search

Home  >  Q&A  >  body text

查看 Git 分支是否已经合并, 有什么好办法?

多人开发使用了较多分支, 有些还没觉得及时清理, 结果积累下来不少,
有些比较容易看出来手动删掉, 有些就不大清楚了...
往 commit history 里看会比较麻烦, 有没有比较方便查看的办法?

另外合并的话, 有时候合的是 git merge branch-a,
有时候合并会是 git merge origin/branch-a,
查看是否合并是否可以不受这个区别的影响?

天蓬老师天蓬老师2812 days ago1174

reply all(4)I'll reply

  • 为情所困

    为情所困2017-04-24 16:02:56

    Try:
    - git branch --merged
    - git branch --no-merged

    reply
    0
  • PHPz

    PHPz2017-04-24 16:02:56

    You can also try git log | grep branch_name

    reply
    0
  • 世界只因有你

    世界只因有你2017-04-24 16:02:56

    Recommend a tool tig
    The effect is as follows:

    Capital M 代表的就是 merge 操作,这样看应该很清晰吧,每个分支的历史都可以看得清清楚楚,当然号称 git 浏览器的 tig does more than that, it has many more powerful features and is worth using.

    reply
    0
  • 某草草

    某草草2017-04-24 16:02:56

    If the branch is explicitly merged, just git branch -d xxx will do. If merge is not displayed, this command will not be executed.

    But some branches may be implicitly merged, that is, their code is merged into the trunk (merge --squash/rebase), but no explicit merge is performed. What should I do in this case? For example, this branch is called feature, and the trunk is master

    git checkout feature
    git rebase master(以master为基 rebase)
    解决下冲突
    这时候feature分支就是以master HEAD为基的分支了,之后是merge还是丢弃随你便。。
    当然rebase后发现feature和master 指向同一个HEAD,那么这个分支肯定是合并过的,直接-d删掉即可
    

    reply
    0
  • Cancelreply