What is the meaning of branch, tag, and trunk?

41

What do they mean and what are the best practices for using them?

    
asked by anonymous 11.06.2014 / 19:52

2 answers

43

Trunk

It is the main trunk of development, 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 gets 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 in the trunk that is used to apply changes to the code while preserving the integrity of the code in trunk . If the changes work as intended, 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. Although trunk is the main repository, all development is usually done over local or remote branches depending on the workflow chosen. It's common to call the branch version of work. It is a draft that can be saved for later, to play away, remain private to a specific developer or group without going into the project.

Where there are many branches can create difficulties in running merge , so more and more distributed versioning systems are becoming increasingly successful on very active projects and mainly decentralized. So it's common not to wildly encourage branches when using SVN.

In many cases branch works as a future release.

Tag

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

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

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

What usually differentiates tag from branch is precisely the stability of the content. You should not have to tinker with a tag repository. It differs from trunk because it is secondary and almost always in the past.

How to use

In open-source projects, branches that 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. Communication between these trees is common, and in some cases even bi-directional. In these cases the trunk of one 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 fewer advantages there are in using this scheme. And it is in fact common, even in small open source projects, that development is essentially done on top of trunk and forks branches of the project.

You need to try out a few different workflows and choose the one that brings the greatest benefit to your project.

Wikipedia illustration :

Basedon link and other page responses.

    
11.06.2014 / 20:05
5

Trunk

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

Branch

One branch let's say of the project, a division of the project based on the main one that is following different lines of thought. Ex: Bug fix for a version that is online would be in a Branch , update or creating another layout would be in another Branch and creating some new functionality might be me different Branch from the previous ones

Tag

Typically used for release releases, the tag marks a stable point of development. The following is an example of A project starts and a repository is created. Eg: myproject 1.0.

    
11.06.2014 / 20:07