241

Possible Duplicate:
What do “branch”, “tag” and “trunk” really mean?

What is a trunk, branch and tag in Subversion and what are the best practices to use them?

What tools can I use for Subversion in Visual Studio 2008?

Community
  • 1
  • 1
Hemanshu Bhojak
  • 15,934
  • 15
  • 46
  • 60
  • ... combined with: http://stackoverflow.com/questions/453481/subversion-plugin-to-visual-studio – Jørn Schou-Rode Mar 17 '10 at 08:46
  • 2
    http://stackoverflow.com/questions/16142: "*[What do “branch”, “tag” and “trunk” really mean?](http://stackoverflow.com/questions/16142/what-do-branch-tag-and-trunk-really-mean)*". – Peter Mortensen Feb 29 '12 at 09:34

9 Answers9

295

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. Also, branches can be used to create development lines for multiple versions of the same product, like having a place to backport bugfixes into a stable release.

Finally, tags are markers to highlight notable revisions in the history of the repository, usually things like "this was released as 1.0".

See the HTML version of "Version Control with Subversion", especially Chapter 4: Branching and Merging or buy it in paper (e.g. from amazon) for an in-depth discussion of the technical details.

As others (e.g. Peter Neubauer below) the underlying implementation as /tags /branches and /trunk directories is only conventional and not in any way enforced by the tools. Violating these conventions leads to confusion all around, as this breaks habits and expectations of others accessing the repository. Special care must be taken to avoid committing new changes into tags, which should be frozen.


I use TortoiseSVN but no Visual Studio integration. I keep the "Check for modifications" dialog open on the second monitor the whole time, so I can track which files I have touched. But see the "Best SVN Tools" question, for more recommendations.

Community
  • 1
  • 1
David Schmitt
  • 54,766
  • 26
  • 117
  • 159
  • 5
    I guess ankh is the best for me. I can do almost everything from right within visual studio. Thanks!!! – Hemanshu Bhojak Apr 01 '09 at 04:56
  • 1
    Fundamentally, the answers provided by @Peter-Neubauer and KOGI (below) are arguably closer to true. As they've noted, David Schmitt's answer here simply explains the _convention_ for how those directories are typically used -- but there's in fact nothing at all magical about those folders per se, or how they're utilized. Thanks to David Schmitt, but +1's to the others for delineating that crucial difference. – rondoagogo Jan 01 '13 at 23:48
  • 2
    "Arguably" the OP asked about the best practices, not the (IMHO pretty weak) implementation of those. – David Schmitt Jan 09 '13 at 09:36
  • 1
    My one penny worth to add here; only trouble I have had so far with a repository that violated this convention was when I tried importing the repo into git, using svn-git. It just doesn't like it if the branches are inappropriately formed. So the summary is, when it comes to tools like svn-git (which you might have to use in the future), they will be tuned to work against a repo that follows these conventions, and might refuse to function correctly/usefully otherwise. – ϹοδεMεδιϲ Aug 09 '14 at 20:34
36

The "trunk", "branches", and "tags" directories are conventions in Subversion. Subversion does not require you to have these directories nor assign special meaning to them. However, this convention is very common and, unless you have a really good reason, you should follow the convention. The book links that other readers have given describe the convention and how to use it.

Peter Neubauer
  • 827
  • 5
  • 4
27

The answer by David Schmitt sums things up very well, but I think it is important to note that, to SVN, the terms 'branch', 'tag', and 'trunk' don't mean anything. These terms are purely semantic and only affect the way we, as users of the system, treat those directories. One could easily name them 'main', 'test', and 'releases.'; As long as everyone using the system understands how to use each section properly, it really doesn't matter what they're called.

KOGI
  • 3,861
  • 2
  • 22
  • 33
  • Yeah it's true. Subversion does not restrict you with such naming conventions. Its just a recommendation. Thanks for your answer, it helped. – Hemanshu Bhojak Apr 01 '09 at 04:54
  • 1
    So does, for example, subversion know the concept of "revision"? Is every single commit just a snapshot of the entire repository? How do you know if someone wipes out 50% of the release tags with one of their check-ins by mistake? Wouldn't you constantly have to watch for that? –  May 05 '13 at 15:00
  • 1
    @ebyrob it's been a while since I've used SVN, but IIRC, SVN tracks diffs between revisions, NOT entire snapshots. Regardless, and in any VCS, there is the potential to "delete" release tags (or any other file/folder for that matter) that you may not want to delete. I put "delete" in quotes, though, because it's never really truly gone, it's always in the history and can always be restored (except for maybe 1 *very* fringe case in GIT, I think) – KOGI May 06 '13 at 16:52
18

A great place to start learning about Subversion is http://svnbook.red-bean.com/.

As far as Visual Studio tools are concerned, I like AnkhSVN, but I haven't tried the VisualSVN plugin yet.

VisualSVN does rely on TortoiseSVN, but TortoiseSVN is also a nice complement to Ankh IMHO.

Peter Mortensen
  • 28,342
  • 21
  • 95
  • 123
Quintin Robinson
  • 76,510
  • 14
  • 116
  • 132
10

To use Subversion in Visual Studio 2008, install TortoiseSVN and AnkhSVN.

TortoiseSVN is a really easy to use Revision control / version control / source control software for Windows. Since it's not an integration for a specific IDE you can use it with whatever development tools you like. TortoiseSVN is free to use. You don't need to get a loan or pay a full years salary to use it.

AnkhSVN is a Subversion SourceControl Provider for Visual Studio. The software allows you to perform the most common version control operations directly from inside the Microsoft Visual Studio IDE. With AnkhSVN you no longer need to leave your IDE to perform tasks like viewing the status of your source code, updating your Subversion working copy and committing changes. You can even browse your repository and you can plug-in your favorite diff tool.

Peter Mortensen
  • 28,342
  • 21
  • 95
  • 123
gimel
  • 73,814
  • 10
  • 69
  • 104
8

A trunk is considered your main code base, a branch offshoot of the trunk. Like, you create a branch if you want to implement a new feature, but don't want to affect the main trunk.

TortoiseSVN has good documentation, and a great diff tool.

I use Visual studio, and I use VisualSVN and TortoiseSVN.

Peter Mortensen
  • 28,342
  • 21
  • 95
  • 123
Mike_G
  • 14,627
  • 11
  • 63
  • 93
6

If you're new to Subversion you may want to check out this post on SmashingMagazine.com, appropriately titled Ultimate Round-Up for Version Control with SubVersion.

It covers getting started with SubVersion with links to tutorials, reference materials, & book suggestions.

It covers tools (many are compatible windows), and it mentions AnkhSVN as a Visual Studio compatible plugin. The comments also mention VisualSVN as an alternative.

Peter Mortensen
  • 28,342
  • 21
  • 95
  • 123
Kevin Williams
  • 2,558
  • 3
  • 24
  • 25
5

A fantastic free utility to use if you have a team of developers is SVN Monitor. It serves as a heartbeat for your tree, telling you when there are updates, possible conflicts, etc. It's not quite as useful for a solo developer though.

Craig Angus
  • 21,343
  • 17
  • 53
  • 62
swilliams
  • 44,959
  • 24
  • 94
  • 129
4

A good book on Subversion is Pragmatic Version Control using Subversion where your question is explained, and it gives a lot more information.

Peter Mortensen
  • 28,342
  • 21
  • 95
  • 123
eKek0
  • 21,835
  • 24
  • 87
  • 117