0

我想从 Git 中跟踪 SVN 上的远程分支。我可以看到如何使用 git-svn 命令执行此操作的基础知识,我希望执行以下操作:

Git branch | SVN branch
-----------------------
master     | Trunk
feature1   | <not mapped>
feature2   | <not mapped>

这样一旦我合并到 git/master,然后执行 dcommit,Trunk 就会被更新,只有最后一次 svn 提交和 git/HEAD 之间的变化。

这可能吗?我该怎么做?

4

1 回答 1

1

git svn文档描述了使用 Subversion 的主干,但使用了一个脏主:

# Clone a repo (like git clone):
    git svn clone http://svn.example.com/project/trunk
# Enter the newly cloned directory:
    cd trunk
# You should be on master branch, double-check with 'git branch'
    git branch
# Do some work and commit locally to git:
    git commit ...
# Something is committed to SVN, rebase your local changes against the
# latest changes in SVN:
    git svn rebase
# Now commit your changes (that were committed previously using git) to SVN,
# as well as automatically updating your working HEAD:
    git svn dcommit
# Append svn:ignore settings to the default git exclude file:
    git svn show-ignore >> .git/info/exclude

在功能分支而不是 master 上做你的工作

git checkout -b feature1
hack ...
git add ...
git commit ...

当您准备好将您的工作重新导入 Subversion 时,请务必保持您的历史线性:

git checkout master
git svn rebase
git rebase master feature1
git checkout master
git merge feature1

装运它!

git svn dcommit
于 2010-01-29T14:27:30.993 回答