[英]How do I know if a branch has already been merged in SVN/Mercurial/Git?
Is there any way of easily deciphering (ie at a glance) whether or not a branch has already previously been merged with the another branch or the trunk? 是否有任何方法可以轻松解密(即一目了然)分支是否先前已与另一个分支或主干合并? The nearest I've been able to figure out is by looking at the commit notes and displaying the merged commit notes.
我能够弄清楚的最近的是查看提交注释并显示合并的提交注释。 The disadvantage with this seems to be that unless you know which branch the commit notes are imported from, there's no way to decipher which branches have already been merged or not.
这样做的缺点似乎是,除非您知道从哪个分支导入提交注释,否则无法解密哪些分支已经合并。
Edit : Is Mercurial or Git any more intuitive than SVN for this? 编辑 :Mercurial或Git是否比SVN更直观?
Is Mercurial or Git any more intuitive than SVN for this?
Mercurial或Git是否比SVN更直观?
Yes, very much so: 是的,非常如此:
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.
| |
EDIT: Git has a git log --graph
option that's pretty much the same as Mercurial's, except without the helpful you-are-here @
character. 编辑: Git有一个
git log --graph
选项与Mercurial的几乎相同,除了没有帮助你在这里@
字符。
On git, you can use git log
to ask if one branch includes another: 在git上,你可以使用
git log
来询问一个分支是否包含另一个分支:
git log topic ^master # list all commits in branch 'topic', but not in 'master'
If nothing is returned, topic
has been merged. 如果未返回任何内容,则
topic
已合并。
Type: 类型:
svn help mergeinfo
And you get: 你得到:
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')
In git, you can use --contains
to list branches that contain other branches: 在git中,您可以使用
--contains
列出包含其他分支的分支:
git branch -a --contains feature
will show all branches (with -a
, that includes remote branches) that have merged the given feature. 将显示已合并给定功能的所有分支(使用
-a
,包括远程分支)。
git show-branch
will show lots of details of the relationships between branches. git show-branch
将显示git show-branch
之间关系的大量细节。 It takes a bit of time to learn to read it effectively, but it's very valuable and will show you a lot in a small amount of space. 学习有效阅读它需要一些时间,但它非常有价值,并会在很小的空间内向您展示。
If you have a version of the server which is at least 1.5 as mentioned by chotchki, and your repository has been created with such a version or upgraded, the property svn:mergeinfo is added to any directory in which a merge has occurred. 如果chotchki提到的服务器版本至少为1.5,并且您的存储库已使用此类版本创建或升级,则属性svn:mergeinfo将添加到发生合并的任何目录中。
Let's say you have reintegrated two branches in the trunk, you can check with (replace with your URL): 假设您已经在主干中重新集成了两个分支,您可以检查(替换为您的URL):
svn propget svn:mergeinfo svn://localhost/Test/trunk
which branches have been merged and which revisions they modified. 合并了哪些分支以及修改了哪些修订。 Example of output:
输出示例:
/branches/dev/1:35-36
/branches/dev/2:38-39
With a GUI client like TortoiseSVN, check at the graph or look at the properties of the target directory in the repo-browser. 使用像TortoiseSVN这样的GUI客户端,检查图表或查看repo-browser中目标目录的属性。
In Git , you can use git branch --merged <commit>
, which lists all branches which are reachable from given commit ( <commit> defaults to HEAD, which means that git branch --merged
would list all branches merged into current commit). 在Git中 ,您可以使用
git branch --merged <commit>
,它列出了从给定提交可以访问的所有分支( <commit>默认为HEAD,这意味着git branch --merged
将列出合并到当前提交的所有分支) 。
Or you can use git show-branch branch1 branch2
or git log --graph --oneline branch1 branch2
to see history graphically (or use some graphical history browser like gitk, QGit, Giggle, GitX, etc.). 或者您可以使用
git show-branch branch1 branch2
或git log --graph --oneline branch1 branch2
以图形方式查看历史记录(或使用一些图形历史记录浏览器,如gitk,QGit,Giggle,GitX等)。
To just see which branches are merged or not with a particular branch, I found Jakub's reply most useful, and the related command: 要查看哪些分支与特定分支合并,我发现Jakub的回复最有用,以及相关命令:
git branch --no-merged
From git help: 从git帮助:
With --no-merged only branches not merged into the named commit will be listed.
使用--no-merged时,仅列出未合并到命名提交的分支。
If you have access to TortoiseSVN and the repo is version 1.5 or later, you could look at repository graph it generates. 如果您有权访问TortoiseSVN并且repo是1.5或更高版本,您可以查看它生成的存储库图。 However SVN in general makes it a pain to track merges.
然而,SVN通常会使跟踪合并变得很困难。
You can use svnmerge.py to manage the branches. 您可以使用svnmerge.py来管理分支。 It tells you which branches have already been merged and it only merges new revisions.
它告诉您哪些分支已经合并,它只合并新的修订版。
You could try to execute the merge with the --dry-run
option and examine the output (ie see if it wants to do the merge or not). 您可以尝试使用
--dry-run
选项执行合并并检查输出(即查看它是否要进行合并)。
Personally, when I merge one branch with another I record the exact range of revision numbers in the commit message. 就个人而言,当我将一个分支与另一个分支合并时,我在提交消息中记录了修订号的确切范围。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.