Skip to main content

Repository layout

If you want to use branches, then normally the first thing to do when creating a new empty repository is to prepare some basic repository layout to organize future branches.

Single-project repository

For a repository that contains just one project, the conventional layout of directories in the repository is as follows:

MyRepo
├── trunk
├── branches
└── tags

The three top-level directories—trunk, branches and tags—are located in the root directory of the repository:

  • trunk - is the directory representing the main line of history.
  • branches - is the directory into which users will put new branches. Each new branch becomes a new subdirectory inside the branches directory. Each branch will contain a ‘copy’ of your project and will represent a diverging, alternative line of history.
  • tags - is the directory into which users will put new tags. A tag is just like a branch, except once created, users by convention do not commit further changes to it. Tagging is typically used to save and set apart some particularly important states of the project’s history. For example, tags can be created for such milestone states as new releases.

The repository layout mentioned above is just a convention. It is possible to have a custom repository layout to organize branches in a way that suits your needs. For example, it is possible to have multiple parent directories for branches (e.g. one for feature branches and another one for stable pre-release branches) instead of having just one branches directory. The directory representing the main line of the project’s history can be called main or master instead of trunk. It is possible to name the tags directory differently as well, for example, it may be named releases.