如何使用 git-svn 切换 svn 分支?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/728931/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 03:38:06  来源:igfitidea点击:

How to switch svn branches using git-svn?

svngitgit-svn

提问by Jauder Ho

Duplicate

复制

How do I make git-svn use a particular svn branch as the remote repository?

如何让 git-svn 使用特定的 svn 分支作为远程存储库?

I am using git-svn to track development by someone else on svn. I'm trying to figure out how to use gti-svn to switch from one svn branch to another. All the examples I have able to find talk about using svn switch as method to switch location instead of actual branches.

我正在使用 git-svn 来跟踪其他人在 svn 上的开发。我想弄清楚如何使用 gti-svn 从一个 svn 分支切换到另一个。我能找到的所有示例都在谈论使用 svn switch 作为切换位置而不是实际分支的方法。

Essentially, I would like to start pulling from /svn/branch/1.3 instead of /svn/branch/1.2 using svn fetch.

本质上,我想开始使用 svn fetch 从 /svn/branch/1.3 而不是 /svn/branch/1.2 拉取。

回答by Jesper R?nn-Jensen

These commands have been incredibly useful for me when working on svn branches via git-svn:

当通过 git-svn 在 svn 分支上工作时,这些命令对我来说非常有用:

#create local Git branch that mirrors remote svn branch

git checkout -b local/RELEASE-0.12 RELEASE-0.12 
#will connect with a remote svn branch named ‘RELEASE-0.12′

# -n will show which svn branch you will commit into:
git svn dcommit --dry-run 

See full explanation in my article on justaddwater.dk.

请参阅我关于justaddwater.dk 的文章中的完整解释。

回答by Can Berk Güder

If you've cloned the SVN repository properly (using -T -b -tor -s), you should be able to use the git branch commands like:

如果您正确克隆了 SVN 存储库(使用-T -b -t-s),您应该能够使用 git branch 命令,例如:

git reset --hard remotes/branch

git checkout branch

etc.

等等。

回答by Klas Mellbourn

From my experience, it works fine doing just

根据我的经验,它工作正常

git checkout -b RELEASE-0.12 RELEASE-0.12

The local/prefix is not needed, and it is less confusing to me to leave it out. The old RELEASE-0.12branch is already a remote branch, so git will not confuse it with the new branch.

local/不需要前缀,它是减少混乱到我离开它。旧RELEASE-0.12分支已经是远程分支,所以git不会把它和新分支混淆。

The command above will not create a tracking branch relationship. But that is not needed, git svn rebaseworks as expected anyway.

上面的命令不会创建跟踪分支关系。但这不是必需的,git svn rebase无论如何都能按预期工作。