问题
我原本预计文件a.txt
会发生合并冲突,因为第2行在trunk
和branch/featurex
同时发生了变化。
svn diff
?重现情况的示例
要重现树冲突,您可以对trunk
和branches/featurex
进行更改,并尝试将trunk
合并到branches/featurex
。
创建分支:
PS C:\> mkdir demo
PS C:\> cd demo
PS C:\demo> svnadmin create svnrepo
PS C:\demo> cd workspace
PS C:\demo\workspace> mkdir trunk
PS C:\demo\workspace> mkdir branches
PS C:\demo\workspace> mkdir tags
PS C:\demo\workspace> svn add trunk
PS C:\demo\workspace> svn add branches
PS C:\demo\workspace> svn add tags
PS C:\demo\workspace> svn ci -m "Create SVN default folders"
PS C:\demo\workspace> cd trunk
PS C:\demo\workspace\trunk> echo "trunk: line1" > a.txt
PS C:\demo\workspace\trunk> svn add .\a.txt
PS C:\demo\workspace\trunk> svn ci -m "1st commit on trunk"
PS C:\demo\workspace\trunk> svn copy . ..\branches\featurex
PS C:\demo\workspace\trunk> cd ..
PS C:\demo\workspace> cd .\branches
PS C:\demo\workspace\branches> svn ci -m "Create branch for feature x"
Adding featurex
Adding (bin) featurex\a.txt
在trunk上提交更改:
PS C:\demo\workspace\trunk> echo "trunk: line2" >> .\a.txt
PS C:\demo\workspace\trunk> svn ci -m "2nd commit on trunk"
在分支上提交更改(在同一行上创建合并冲突):
PS C:\demo\workspace\branches\featurex> svn up
PS C:\demo\workspace\branches\featurex> echo "branch: line2" >> .\a.txt
PS C:\demo\workspace\branches\featurex> svn ci -m "1st commit on branch"
将主干合并到分支:
PS C:\demo\workspace\branches\featurex> svn up
PS C:\demo\workspace\branches\featurex> svn merge file:///c:/demo/svnrepo/trunk
--- Merging r2 through r5 into '.':
C a.txt
--- Recording mergeinfo for merge of r2 through r5 into '.':
U .
Summary of conflicts:
Tree conflicts: 1
PS C:\demo\workspace\branches\featurex>
它是:意外的树冲突。
a.txt
的内容并未显示与合并冲突的任何合并,它只显示"分支版本"有了这个内容:
trunk: line1
branch: line2
版本
Subversion版本1.7.8(r1419691)编译于2012年12月12日,21:11:09
答案 0 :(得分:0)
PS C:\demo\workspace\trunk> svn copy . ..\branches\featurex PS C:\demo\workspace\trunk> cd .. PS C:\demo\workspace> cd .\branches PS C:\demo\workspace\branches> svn ci -m "Create branch for feature x"
是不创建分支的正确方法,如
这样的事实所证明Adding featurex Adding (bin) featurex\a.txt
没有提到它们是副本。要使它们复制,源必须是存储库URL(并且目标也应该是)。尝试使用以下方法创建分支:
PS C:\demo\workspace\trunk> svn copy -m "Create branch for feature x" "^/trunk" "^/branches/featurex"
(当您在工作副本中时,^
是存储库根目录的别名)后跟svn update
。或者更确切地说svn switch
- 除了在一次提交而不是三次提交中创建初始结构之外,你不应该检查多个分支!