What is the difference between trunk and branch in svn




















Knowledge of source control systems is a must for any professional programmer. New users of subversion are often confused between three things trunk, tags, and branches. Questions like, what is the difference between a tag and a branch in subversion is frequently asked in various Java forums and chat rooms.

In this article, we will see what is trunk, tags or branches in SVN and understand the difference between trunk, tag, and branch.

In short, when you first upload your project to SVN it creates a trunk, It's analogous to the trunk of a tree. When multiple developer works on the different functionality of project they usually create a branch from trunk and after successfully completing that functionality, they usually merge there changes to trunk. On the other hand tag is usually used to create read only snapshots of either trunk or branch, which has been released, for future use.

You can think tag as stable snapshot of code at any point, and can be used to a s backup or resto re. Let's see the difference between branch, trunk and tag more detail in next section. Technically all three i. If you are using tortoise SVN, a popular windows client for subversion, you can explore trunk, branch or tag. If you browse SVN repository using Repo browser or simply open it on any browser e. Internet Explorer, you will generally see three directories as trunk, branch and tags at root of project.

This is actually one of SVN best practice to create this kind of directory structure. As I said earlier, trunk is place where main development happens, and branches are places where different developer work on different functionalities. This division is purely based on how programmer uses trunk and branches.

Similarly, tags are used to backup releases e. Main difference between branch and tag in subversion is that, tag is a read only copy of source code at a ny point and no further change on tag is accepted, while branch is mainly for development.

Other source control like CVS doesn't allow modification on tags but SVN allows changes on tags, which is considered as bad practice. You should not be making any change on tag once created, it should be treated as read only copy of source code only for restore purpose. After completion of a functionality, a branch is usually merged back into trunk. That's all on difference between trunk, branch and tags in Subversion or SVN.

They are mostly categorized based upon there usage. Though trunk, branch and tag are quite common words in source control, and other SCM also uses these words, there behavior may be little different on other SCM, so don't forget to check SCM documentation.

Other Programming articles from Javarevisited Blog. How to Swap two numbers with using third variable in Java. Press OK to commit the new copy to the repository. Don't forget to supply a log message. Note that the copy is created inside the repository.

Note that unless you opted to switch your working copy to the newly created branch, creating a Branch or Tag does not affect your working copy. Even if you create the branch from your WC, those changes are committed to the new branch, not to the trunk, so your WC may still be marked as modified with respect to the trunk.

You can also create a branch or tag without having a working copy. To do that, open the repository browser. You can there drag folders to a new location. You have to hold down the Ctrl key while you drag to create a copy, otherwise the folder gets moved, not copied.

You can also drag a folder with the right mouse button. Once you release the mouse button you can choose from the context menu whether you want the folder to be moved or copied.

Of course to create a branch or tag you must copy the folder, not move it. Yet another way is from the log dialog. You can show the log dialog for e. Good for the network load, good for your patience. To be able to work with your freshly generated branch or tag you have several ways to handle it. You can:. You can check out to any location on your local disk and you can create as many working copies from your repository as you like.

Switch your current working copy to the newly created copy in the repository. In the next dialog enter the URL of the branch you just created.

Select the Head Revision radio button and click on OK. Switch works just like Update in that it never discards your local changes. Any changes you have made to your working copy which have not yet been committed will be merged when you do the Switch. If you do not want this to happen then you must either commit the changes before switching, or revert your working copy to an already-committed revision typically HEAD. In short — A trunk in SVN is main development area, where major development happens.

After completion of a functionality, a branch is usually merged back into trunk. They are mostly categorized based upon there usage. Regards, Rajesh Kumar Twitt me twitter. Slide 1.

Excellent Education Program. Innovative Methods of Teaching. Learn More. Slide 2. Learning Through Play. Devoted to the Early Education.



0コメント

  • 1000 / 1000