index.md 7.0 KB
Newer Older
1 2
# Subgroups

D
dappelt 已提交
3
NOTE: **Note:**
4 5
[Introduced][ce-2772] in GitLab 9.0. Not available when using MySQL as external
database (support removed in GitLab 9.3 [due to performance reasons][issue]).
6

7
With subgroups (aka nested groups or hierarchical groups) you can have
8 9 10 11 12 13 14 15 16 17
up to 20 levels of nested groups, which among other things can help you to:

- **Separate internal / external organizations.** Since every group
  can have its own visibility level, you are able to host groups for different
  purposes under the same umbrella.
- **Organize large projects.** For large projects, subgroups makes it
  potentially easier to separate permissions on parts of the source code.
- **Make it easier to manage people and control visibility.** Give people
  different [permissions][] depending on their group [membership](#membership).

18 19 20 21 22 23
## Database Requirements

Nested groups are only supported when you use PostgreSQL. Supporting nested
groups on MySQL in an efficient way is not possible due to MySQL's limitations.
See the following links for more information:

24 25
- <https://gitlab.com/gitlab-org/gitlab-ce/issues/30472>
- <https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/10885>
26

27 28 29
## Overview

A group can have many subgroups inside it, and at the same time a group can have
30
only 1 parent group. It resembles a directory behavior or a nested items list:
31

32 33 34 35 36 37
- Group 1
  - Group 1.1
  - Group 1.2
      - Group 1.2.1
      - Group 1.2.2
          - Group 1.2.2.1
38 39 40 41

In a real world example, imagine maintaining a GNU/Linux distribution with the
first group being the name of the distro and subsequent groups split like:

42 43 44 45 46 47 48 49 50 51 52
- Organization Group - GNU/Linux distro
  - Category Subgroup - Packages
      - (project) Package01
      - (project) Package02
  - Category Subgroup - Software
      - (project) Core
      - (project) CLI
      - (project) Android app
      - (project) iOS app
  - Category Subgroup - Infra tools
      - (project) Ansible playbooks
53 54 55

Another example of GitLab as a company would be the following:

56
- Organization Group - GitLab
P
Pascal Borreli 已提交
57
  - Category Subgroup - Marketing
58 59 60 61 62 63 64 65 66 67 68
      - (project) Design
      - (project) General
  - Category Subgroup - Software
      - (project) GitLab CE
      - (project) GitLab EE
      - (project) Omnibus GitLab
      - (project) GitLab Runner
      - (project) GitLab Pages daemon
  - Category Subgroup - Infra tools
      - (project) Chef cookbooks
  - Category Subgroup - Executive team
69 70 71 72 73 74 75 76 77 78 79 80

---

The maximum nested groups a group can have, including the first one in the
hierarchy, is 21.

Things like transferring or importing a project inside nested groups, work like
when performing these actions the traditional way with the `group/project`
structure.

## Creating a subgroup

D
dappelt 已提交
81
NOTE: **Note:**
82 83 84 85 86 87 88
You need to be an Owner of a group in order to be able to create a subgroup. For
more information check the [permissions table][permissions].
For a list of words that are not allowed to be used as group names see the
[reserved names][reserved].
Users can always create subgroups if they are explicitly added as an Owner to
a parent group even if group creation is disabled by an administrator in their
settings.
89 90 91

To create a subgroup:

J
James Ramsay 已提交
92 93
1. In the group's dashboard expand the **New project** split button, select
   **New subgroup** and click the **New subgroup** button.
94 95 96 97 98 99 100 101 102 103 104 105

    ![Subgroups page](img/create_subgroup_button.png)

1. Create a new group like you would normally do. Notice that the parent group
   namespace is fixed under **Group path**. The visibility level can differ from
   the parent group.

    ![Subgroups page](img/create_new_group.png)

1. Click the **Create group** button and you will be taken to the new group's
   dashboard page.

106
Follow the same process to create any subsequent groups.
107 108 109 110 111 112 113

## Membership

When you add a member to a subgroup, they inherit the membership and permission
level from the parent group. This model allows access to nested groups if you
have membership in one of its parents.

114 115 116
The group permissions for a member can be changed only by Owners and only on
the **Members** page of the group the member was added.

117 118 119 120 121 122 123
You can tell if a member has inherited the permissions from a parent group by
looking at the group's **Members** page.

![Group members page](img/group_members.png)

From the image above, we can deduct the following things:

124 125 126
- There are 5 members that have access to the group `four`
- User0 is a Reporter and has inherited their permissions from group `one`
  which is above the hierarchy of group `four`
127
- User1 is a Developer and has inherited their permissions from group
128
  `one/two` which is above the hierarchy of group `four`
129
- User2 is a Developer and has inherited their permissions from group
130 131 132 133 134
  `one/two/three` which is above the hierarchy of group `four`
- For User3 there is no indication of a parent group, therefore they belong to
  group `four`, the one we're inspecting
- Administrator is the Owner and member of **all** subgroups and for that reason,
  same as User3, there is no indication of an ancestor group
135

136 137
### Overriding the ancestor group membership

D
dappelt 已提交
138
NOTE: **Note:**
139 140
You need to be an Owner of a group in order to be able to add members to it.

D
dappelt 已提交
141
NOTE: **Note:**
D
dappelt 已提交
142 143 144
A user's permissions in a subgroup cannot be lower than in any of its ancestor groups.
Therefore, you cannot reduce a user's permissions in a subgroup with respect to its ancestor groups.

145
To override a user's membership of an ancestor group (the first group they were
D
dappelt 已提交
146
added to), add the user to the new subgroup again with a higher set of permissions.
147

148
For example, if User0 was first added to group `group-1/group-1-1` with Developer
149
permissions, then they will inherit those permissions in every other subgroup
M
Mark Chao 已提交
150 151
of `group-1/group-1-1`. To give them Maintainer access to `group-1/group-1-1/group1-1-1`,
you would add them again in that group as Maintainer. Removing them from that group,
152
the permissions will fallback to those of the ancestor group.
153 154 155 156

## Mentioning subgroups

Mentioning groups (`@group`) in issues, commits and merge requests, would
A
Achilleas Pipinellis 已提交
157
notify all members of that group. Now with subgroups, there is a more granular
158
support if you want to split your group's structure. Mentioning works as before
A
Achilleas Pipinellis 已提交
159
and you can choose the group of people to be notified.
160 161 162 163 164 165 166

![Mentioning subgroups](img/mention_subgroups.png)

## Limitations

Here's a list of what you can't do with subgroups:

167 168 169 170 171
- [GitLab Pages](../../project/pages/index.md) supports projects hosted under
  a subgroup, but not subgroup websites.
  That means that only the highest-level group supports
  [group websites](../../project/pages/introduction.html#user-or-group-pages),
  although you can have project websites under a subgroup.
172 173 174 175 176 177 178 179
- It is not possible to share a project with a group that's an ancestor of
  the group the project is in. That means you can only share as you walk down
  the hierarchy. For example, `group/subgroup01/project` **cannot** be shared
  with `group`, but can be shared with `group/subgroup02` or
  `group/subgroup01/subgroup03`.

[ce-2772]: https://gitlab.com/gitlab-org/gitlab-ce/issues/2772
[permissions]: ../../permissions.md#group
B
Bob Van Landuyt 已提交
180
[reserved]:  ../../reserved_names.md
181
[issue]: https://gitlab.com/gitlab-org/gitlab-ce/issues/30472#note_27747600