如何在 XCode (SVN) 中使用分支

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

How to work with branches in XCode (SVN)

xcodesvnbranch

提问by Julien

I successfully set up SVN and XCode, it's really cool ! I commit, update, I even tag (in the Terminal though...) ! All this is pretty easy Now I'd like to work with different branches, but I'm a bit confused.

我成功设置了SVN和XCode,真的很酷!我提交,更新,我什至标记(尽管在终端中......)!所有这一切都非常简单 现在我想使用不同的分支,但我有点困惑。

I'v followed this tutorial, and it has a section about branching. What it says is to use this script :

我遵循了本教程,它有一个关于分支的部分。它说的是使用这个脚本:

#!/bin/ksh
# A script to branch a SVN trunk
reporoot=/Library/Subversion/Repository/
projdir=Projects

# Prompt for repository name
print -n "Enter repository name:"
read repo

# Prompt for project name
print -n "Enter project name:"
read project

# Prompt for branch name
print -n "Enter branch name:"
read branch

# Create branch
svn copy file://$reporoot/$repo/$projdir/$project/trunk file://$reporoot/$repo/$projdir/$project/branches/$branch -m "Creating a branch of the ‘$project‘ project."

echo
echo Creation of a branch of the $project project complete!
echo

But what I see is it's just a shell script that copies the current trunk to a branch (like a tag). And so if I do this, I will still be committing in the trunk no ?

但我看到的是它只是一个将当前主干复制到分支(如标签)的 shell 脚本。所以如果我这样做,我仍然会在后备箱中提交,不是吗?

Do you have any idea of a way to be able to "switch" easily between branches, for updates and commit ?

您是否知道一种能够在分支之间轻松“切换”、更新和提交的方法?

Thank you very much.

非常感谢。

回答by Tom van der Woerdt

subversion doesn't have a branch system. This is why you usually see a folder with "trunk", "tags" and "branches" in it. If you want to be able to switch between branches and the trunk effectively, you would probably have to create a symlink to the branch you are using. If you later wish to switch branches, you simply re-create this symlink.

subversion 没有分支系统。这就是为什么您通常会看到一个包含“trunk”、“tags”和“branches”的文件夹。如果您希望能够有效地在分支和主干之间切换,您可能必须创建一个指向您正在使用的分支的符号链接。如果您以后希望切换分支,只需重新创建此符号链接即可。

I am not sure whether Xcode likes this though, or not.

不过我不确定 Xcode 是否喜欢这个。

回答by Stas

Try XCode 4, it allows to create branches, switch and merge them in full mode, not the way XCode 3 used to do it.

试试 XCode 4,它允许在完整模式下创建分支、切换和合并它们,而不是 XCode 3 过去的方式。

UPDATED: You should use svn switchafter you create your new branch. It will update you working copy.

更新:您应该在创建新分支后使用svn switch。它会更新你的工作副本。

Example:

例子:

svn switch http://[email protected]:8080/svn/alb.iphone/Branches/SuperFastAlgo

Full description is here

完整说明在这里

回答by hlfcoding

I would use Git over SVN and use GitX. You'll have a much easier time working with branches, especially if you want to use them practically and not spend half an hour on merges. The XCode3 SCM integration isn't particularly full-featured. If at all possible, I'd try XCode4 with Git, and clone and add vendor libraries as submodules. (This is all somewhat SOP as of 2012).

我会在 SVN 上使用 Git 并使用 GitX。您将更轻松地使用分支,特别是如果您想实际使用它们而不是在合并上花费半小时。XCode3 SCM 集成并不是特别完整。如果可能的话,我会用 Git 尝试 XCode4,然后克隆和添加供应商库作为子模块。(这都是 2012 年的 SOP)。

You can always use git svncommands (sample tutorial).

您始终可以使用git svn命令(示例教程)。

There's also an Objective-C .gitignore Github project. Having the Git repo only physically in the project root also is a big plus.

还有一个Objective-C .gitignore Github 项目。仅在项目根目录中实际拥有 Git 存储库也是一大优势。