我使用git-svn,并注意到在执行
git svn rebase
后需要修复合并冲突时,例如git checkout
的--ours
和--theirs
选项的含义被颠倒了。也就是说,如果存在冲突,我想要保留来自SVN服务器的版本并丢弃本地所做的更改,则必须使用ours
,而我原本预期应该使用theirs
。
这是为什么呢?
示例:
mkdir test
cd test
svnadmin create svnrepo
svn co file://$PWD/svnrepo svnwc
cd svnwc
echo foo > test.txt
svn add test.txt
svn ci -m 'svn commit 1'
cd ..
git svn clone file://$PWD/svnrepo gitwc
cd svnwc
echo bar > test.txt
svn ci -m 'svn commit 2'
cd ..
cd gitwc
echo baz > test.txt
git commit -a -m 'git commit 1'
git svn rebase
git checkout --ours test.txt
cat test.txt
# shows "bar" but I expect "baz"
git checkout --theirs test.txt
cat test.txt
# shows "baz" but I expect "bar"