What do “branch”, “tag” and “trunk” mean in Subversion repositories?

前端 未结 16 1345
后悔当初
后悔当初 2020-11-22 11:51

I\'ve seen these words a lot around Subversion (and I guess general repository) discussions.
I have been using SVN for my projects for the last few year

16条回答
  •  囚心锁ツ
    2020-11-22 12:21

    In general (tool agnostic view), a branch is the mechanism used for parallel development. An SCM can have from 0 to n branches. Subversion has 0.

    • Trunk is a main branch recommended by Subversion, but you are in no way forced to create it. You could call it 'main' or 'releases', or not have one at all!

    • Branch represents a development effort. It should never be named after a resource (like 'vonc_branch') but after:

      • a purpose 'myProject_dev' or 'myProject_Merge'
      • a release perimeter 'myProjetc1.0_dev'or myProject2.3_Merge' or 'myProject6..2_Patch1'...
    • Tag is a snapshot of files in order to easily get back to that state. The problem is that tag and branch is the same in Subversion. And I would definitely recommend the paranoid approach:

      you can use one of the access control scripts provided with Subversion to prevent anyone from doing anything but creating new copies in the tags area.

    A tag is final. Its content should never change. NEVER. Ever. You forgot a line in the release note? Create a new tag. Obsolete or remove the old one.

    Now, I read a lot about "merging back such and such in such and such branches, then finally in the trunk branch". That is called merge workflow and there is nothing mandatory here. It is not because you have a trunk branch that you have to merge back anything.

    By convention, the trunk branch can represent the current state of your development, but that is for a simple sequential project, that is a project which has:

    • no 'in advance' development (for the preparing the next-next version implying such changes that they are not compatible with the current 'trunk' development)
    • no massive refactoring (for testing a new technical choice)
    • no long-term maintenance of a previous release

    Because with one (or all) of those scenario, you get yourself four 'trunks', four 'current developments', and not all you do in those parallel development will necessarily have to be merged back in 'trunk'.

提交回复
热议问题