使用 git svn 签出远程分支
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3239759/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Checkout remote branch using git svn
提问by markovuksanovic
I have checked out a svn repository using git svn. Now I need to checkout one of the branches and track it. Which is the best way to do it?
我已经使用 git svn 检查了一个 svn 存储库。现在我需要检查分支之一并跟踪它。哪种方法最好?
回答by Greg Bacon
Standard Subversion layout
标准颠覆布局
Create a git clone of that includes your Subversion trunk, tags, and branches with
创建一个包含你的 Subversion 主干、标签和分支的 git clone
git svn clone http://svn.example.com/project -T trunk -b branches -t tags
The --stdlayout
option is a nice shortcut if your Subversion repository uses the typical structure:
--stdlayout
如果您的 Subversion 存储库使用典型结构,则该选项是一个不错的快捷方式:
git svn clone http://svn.example.com/project --stdlayout
Make your git repository ignore everything the subversion repo does:
让你的 git 仓库忽略 subversion 仓库所做的一切:
git svn show-ignore >> .git/info/exclude
You should now be able to see all the Subversion branches on the git side:
您现在应该能够在 git 端看到所有 Subversion 分支:
git branch -r
Say the name of the branch in Subversion is waldo
. On the git side, you'd run
假设 Subversion 中分支的名称是waldo
. 在 git 方面,你会跑
git checkout -b waldo-svn remotes/waldo
The -svn suffix is to avoid warnings of the form
-svn 后缀是为了避免形式的警告
warning: refname 'waldo' is ambiguous.
To update the git branch waldo-svn
, run
要更新 git 分支waldo-svn
,请运行
git checkout waldo-svn git svn rebase
Starting from a trunk-only checkout
从仅行李箱结帐开始
To add a Subversion branch to a trunk-only clone, modify your git repository's .git/config
to contain
要将 Subversion 分支添加到仅主干克隆,请修改您的 git 存储库.git/config
以包含
[svn-remote "svn-mybranch"] url = http://svn.example.com/project/branches/mybranch fetch = :refs/remotes/mybranch
You'll need to develop the habit of running
你需要养成跑步的习惯
git svn fetch --fetch-all
to update all of what git svn
thinks are separate remotes. At this point, you can create and track branches as above. For example, to create a git branch that corresponds to mybranch, run
更新所有git svn
认为是单独的遥控器。此时,您可以像上面一样创建和跟踪分支。例如,要创建一个对应于 mybranch 的 git 分支,运行
git checkout -b mybranch-svn remotes/mybranch
For the branches from which you intend to git svn dcommit
, keep their histories linear!
对于您打算从中的分支git svn dcommit
,保持他们的历史线性!
Further information
更多信息
You may also be interested in reading an answer to a related question.