What does branch, tag and trunk mean?

Asked

Viewed 21,131 times

44

What they mean and what best practices to use them?

  • 6

    Although it is considered a little broad, I find this question extremely pertinent, and it is doubtful of several people starting in the development of versioning projects. + 1

2 answers

48


Trunk

It is the main development trunk, following from the beginning of the project to the present. This is where the project should always be based. It is usually managed by a developer and receives merges after approval from someone who is responsible for the project. It makes no sense to exist more than a trunk.

Branch

It is a branch of the development tree. It is a copy of the code derived from a certain point of the trunk which is used for the application of code changes, preserving the integrity of the code in the trunk. If the changes work according to plan, they are usually merged back into the main trunk (trunk). It is widely used for experiments and for parallel developments.

It is used all the time. Despite the trunk be the main repository, all development is usually done on top of local or remote branches depending on the chosen workflow. It is common to call the branch working version. It is a draft that can be saved for later, to play out, remain private for a specific developer or group without entering the project.

Where there are many branches may create difficulties in executing the merge, so more and more distributed version control systems are making more and more success in very active and mainly decentralized projects. That’s why it’s common not to encourage branches uncontrollably when using SVN.

In many cases the branch works as a future version.

Tag

It is a marker of a code state at a given time. It is a point in time at trunk or in a branch that you wish to preserve. The two main reasons for preservation would be:

  • this is a major release of the software, whether alpha, beta, RC or RTM;
  • this is the most stable point of the software before applying important revisions on the trunk.

It’s not common to work on top of a tag. A milestone is created that can be accessed easily. When you find a bug in old version that needs a solution, it is easy to create a branch on top of it to make the repair.

The one that usually differentiates tag of branch is precisely the stability of the content. You should not touch a repository tag. It differs from the trunk by being something secondary and almost always in the past.

How to use

In open source projects, the branches which are not accepted in trunk by project participants can become the basis for Forks, for example.

Fork is usually a completely new repository, with its own trunk but that is derived from an original repository (even if this is already a Fork). It is a new development tree but created from another tree. It is common to have communication between these trees and in some cases even bidirectionally. In these cases the trunk of a ends up functioning as branch of another. In this way it is perceived that these concepts are very abstract.

The concepts presented are recommendations. Nothing prevents developers from doing it in a totally different way if it is more suitable for the project. This is a consecrated form and probably more suitable for most cases. The smaller the team and the more centralized the process, the less advantages there are in using this scheme. And in fact it is common even in projects open source small, that development ends up being done essentially on top of the trunk and Forks usually work as branches of the project.

You need to experience some different workflows and choose the one that brings the greatest benefit to your project.

Illustration from Wikipedia:

Fluxo

Based on What do "branch", "tag" and "trunk" Mean in Subversion repositories? and other answers on the page.

8

Trunk

Main folder, as in a tree the trunk, in it is the project that is stable and that will serve as a basis for new Branchs. Usually contains the most current project files as well as bug fixes and the latest features added to the project.

Branch

A say branch of the project, a division of the project based on the main but following different lines of thought Ex: Bug fixing of a version that is online would be in a Branch, the update or creation of another layout would be in another Branch and the creation of some new functionality could be me another Branch different from previous

Tag

Typically used for "release" releases, the tag marks a stable point of development. Following is an example of use A project starts and a repository is created. Ex.: myproject 1.0.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.