简体   繁体   English

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

[英]How to switch svn branches using git-svn?

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. 我正在使用git-svn跟踪svn上的其他人的开发。 I'm trying to figure out how to use gti-svn to switch from one svn branch to another. 我试图弄清楚如何使用gti-svn从一个svn分支切换到另一个svn分支。 All the examples I have able to find talk about using svn switch as method to switch location instead of actual branches. 我能够找到的所有示例都讨论了使用svn开关作为切换位置而不是实际分支的方法。

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。

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上的文章中的完整说明。

If you've cloned the SVN repository properly (using -T -b -t or -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. 等等

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. 不需要local/前缀,让我不用担心它。 The old RELEASE-0.12 branch is already a remote branch, so git will not confuse it with the new branch. 旧的RELEASE-0.12分支已经是一个远程分支,因此git不会将它与新分支混淆。

The command above will not create a tracking branch relationship. 上面的命令不会创建跟踪分支关系。 But that is not needed, git svn rebase works as expected anyway. 但这不是必需的, git svn rebase无论如何都能正常工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM