我怎么知道分支是否已经在SVN/Mercurial/Git中合并?

Bob*_*der 6 svn git mercurial user-interface

是否有任何方法可以轻松解密(即一目了然)分支是否先前已与另一个分支或主干合并?我能够弄清楚的最近的是查看提交注释并显示合并的提交注释.这样做的缺点似乎是,除非您知道从哪个分支导入提交注释,否则无法解密哪些分支已经合并.

编辑:Mercurial或Git是否比SVN更直观?

Ste*_*osh 10

Mercurial或Git是否比SVN更直观?

是的,非常如此:

sjl at ecgtheow in ~/src/hg-review on webui at tip
[10] $ hg glog
@  changeset: 113:c5debb475273 Steve Losh tip webui
|  summary:   Add file folding.
|
o  changeset: 112:a3ad66636756 Steve Losh  webui
|  summary:   Show skipped-line comments.
|
o  changeset: 111:2e65351af702 Steve Losh  webui
|  summary:   Rough cut of line-level comments.
|
| o  changeset: 110:b599ca22418d Steve Losh  
|/|  summary:   Merge the bug fix.
| |
o |  changeset: 109:e2ddb8631463 Steve Losh  webui
| |  summary:   Fix the event not defined bug.
| |
| o  changeset: 108:001f5ecfd9bc Steve Losh  
|/|  summary:   Merge the webui skipped line counts -- too important to leave in the
| |             branch.
| |
o |  changeset: 107:1cc8e18b1b43 Steve Losh  webui
| |  summary:   Add skipped line counts to diffs.
| |
Run Code Online (Sandbox Code Playgroud)

编辑: Git有一个git log --graph与Mercurial几乎相同的选项,除了没有帮助你在这里的@角色.


bdo*_*lan 7

在git上,您可以使用git log询问一个分支是否包含另一个分支:

git log topic ^master # list all commits in branch 'topic', but not in 'master'
Run Code Online (Sandbox Code Playgroud)

如果没有返回任何内容,topic则已合并.


Ber*_*ben 6

类型:

svn help mergeinfo
Run Code Online (Sandbox Code Playgroud)

你会得到:

mergeinfo: Display merge-related information.
usage: mergeinfo SOURCE[@REV] [TARGET[@REV]]

  Display information related to merges (or potential merges) between
  SOURCE and TARGET (default: '.').  If the --show-revs option
  is not provided, display revisions which have been merged from
  SOURCE to TARGET; otherwise, display the type of information
  specified by the --show-revs option.

Valid options:
  -r [--revision] ARG      : ARG (some commands also take ARG1:ARG2 range)
                             A revision argument can be one of:
                                NUMBER       revision number
                                '{' DATE '}' revision at start of the date
                                'HEAD'       latest in repository
                                'BASE'       base rev of item's working copy
                                'COMMITTED'  last commit at or before BASE
                                'PREV'       revision just before COMMITTED
  --show-revs ARG          : specify which collection of revisions to display
                             ('merged', 'eligible')
Run Code Online (Sandbox Code Playgroud)


Red*_*yph 5

如果您的服务器版本至少为 chotchki 提到的 1.5,并且您的存储库已使用此类版本创建或升级,则属性 svn:mergeinfo 将添加到发生合并的任何目录中。

假设您已经在主干中重新集成了两个分支,您可以检查(替换为您的 URL):

svn propget svn:mergeinfo svn://localhost/Test/trunk
Run Code Online (Sandbox Code Playgroud)

哪些分支已被合并以及它们修改了哪些修订。输出示例:

/branches/dev/1:35-36
/branches/dev/2:38-39
Run Code Online (Sandbox Code Playgroud)

使用 TortoiseSVN 等 GUI 客户端,检查图表或查看存储库浏览器中目标目录的属性。


Dus*_*tin 5

在git中,您可以--contains用来列出包含其他分支的分支:

git branch -a --contains feature
Run Code Online (Sandbox Code Playgroud)

将显示-a已合并给定功能的所有分支(带有,包括远程分支)。

git show-branch将显示许多分支之间关系的详细信息。学习有效阅读它需要花费一些时间,但是它非常有价值,并且会在很小的空间内向您展示很多内容。