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

时间:2009-10-25 15:25:56

标签: svn git user-interface mercurial

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

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

10 个答案:

答案 0 :(得分: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.
| |

编辑: Git有一个git log --graph选项,与Mercurial的选项几乎相同,只是没有帮助你的@字符。

答案 1 :(得分:7)

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

git log topic ^master # list all commits in branch 'topic', but not in 'master'

如果未返回任何内容,则topic已合并。

答案 2 :(得分:5)

类型:

svn help mergeinfo

你得到:

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')

答案 3 :(得分:5)

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

git branch -a --contains feature

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

git show-branch将显示分支之间关系的大量细节。学习有效阅读它需要一些时间,但它非常有价值,并会在很小的空间内向你展示。

答案 4 :(得分:4)

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

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

svn propget svn:mergeinfo svn://localhost/Test/trunk

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

/branches/dev/1:35-36
/branches/dev/2:38-39

使用像TortoiseSVN这样的GUI客户端,检查图表或查看repo-browser中目标目录的属性。

答案 5 :(得分:3)

Git 中,您可以使用git branch --merged <commit>,其中列出了从给定提交可以访问的所有分支(&lt; commit&gt; 默认为HEAD,这意味着git branch --merged将列出合并到当前提交的所有分支。)

或者您可以使用git show-branch branch1 branch2git log --graph --oneline branch1 branch2以图形方式查看历史记录(或使用gitk,QGit,Giggle,GitX等图形历史浏览器)。

答案 6 :(得分:1)

要查看哪些分支与特定分支合并,我发现Jakub's reply最有用,以及相关命令:

git branch --no-merged

来自git help:

  

使用--no-merged时,只列出未合并到命名提交的分支。

答案 7 :(得分:0)

如果您有权访问TortoiseSVN并且repo是1.5或更高版本,您可以查看它生成的存储库图。然而,SVN通常会使跟踪合并变得很痛苦。

答案 8 :(得分:0)

您可以使用svnmerge.py来管理分支机构。它告诉您哪些分支已经合并,它只合并新的修订版。

答案 9 :(得分:0)

您可以尝试使用--dry-run选项执行合并并检查输出(即查看是否要进行合并)。

就个人而言,当我将一个分支与另一个分支合并时,我会在提交消息中记录修订号的确切范围。