Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Subversion: Can I checkout, modify, and then make it a branch?

I did a checkout from my trunk to a local DIR and made lots of local changes there. Now I don't want to commit it back to the trunk, but I'd rather make a branch from this local version. Is that possible?

Can I just copy the trunk to a branch, and then cd DIR and svn switch to the branch?

UPDATE: Thanks for the answers, it worked! To summarize the steps:

  • cd DIR
  • svn copy . new-branch-URL
  • svn switch new-branch-URL .

(note the dots)

like image 651
Frank Avatar asked Aug 20 '09 21:08

Frank


People also ask

What happens when a branch is created in Subversion?

Subversion Branching Strategies Subversion branches (SVN branches) allow your team to work on multiple versions of your code simultaneously. Developers can test out new features without impacting the rest of development with errors and bugs. SVN's “branch” directory runs parallel to the “trunk” directory.

What does checkout in svn do?

svn checkout checks out (retrieves) a working copy of the repository into the specified folder. If you don't have access to the repository, and there's not already a current copy of the source in the folder, you can't possibly do a build. If there is a current copy of the source there, it should include build.

What is the difference between trunk and branch in svn?

The trunk is the main line of development in a SVN repository. A branch is a side-line of development created to make larger, experimental or disrupting work without annoying users of the trunk version.


2 Answers

The SVN Book (http://svnbook.red-bean.com/en/1.6/svn-book.html#svn.branchmerge.using.create) doesn't recommend creating a branch from the local working copy.

While it's also possible to create a branch by using svn copy to duplicate a directory within the working copy, this technique isn't recommended. It can be quite slow, in fact! Copying a directory on the client side is a linear-time operation, in that it actually has to duplicate every file and subdirectory within that working copy directory on the local disk.

Instead, create the branch first and then use the svn switch command so you can commit your changes. If your working copy is significantly out of date with the trunk then append "@REV" to the source URL where "REV" is the revision of your working copy reported by svn info.

Copying a directory on the server, however, is a constant-time operation, and it's the way most people create branches.

$ svn copy http://svn.example.com/repos/calc/trunk \            http://svn.example.com/repos/calc/branches/my-calc-branch \       -m "Creating a private branch of /calc/trunk." 
like image 83
Lucas Avatar answered Sep 29 '22 16:09

Lucas


According to its command line help svn copy can copy from a directory to a repository URL. So you should be able to copy your working copy to the branch, e.g.:

svn copy working_directory url_to_branch 
like image 44
wierob Avatar answered Sep 29 '22 14:09

wierob