Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 1 | = Gerrit Code Review - Project Configuration |
Shawn O. Pearce | d2b73db | 2009-01-09 11:55:47 -0800 | [diff] [blame] | 2 | |
Edwin Kempin | f2b47e2 | 2014-04-24 13:00:28 +0200 | [diff] [blame] | 3 | [[project-creation]] |
Edwin Kempin | 53ae7d2 | 2014-04-17 12:53:16 +0200 | [diff] [blame] | 4 | == Project Creation |
Shawn O. Pearce | 6e75221 | 2009-08-12 12:22:12 -0700 | [diff] [blame] | 5 | |
Edwin Kempin | 53ae7d2 | 2014-04-17 12:53:16 +0200 | [diff] [blame] | 6 | There are several ways to create a new project in Gerrit: |
Shawn O. Pearce | 6e75221 | 2009-08-12 12:22:12 -0700 | [diff] [blame] | 7 | |
Edwin Kempin | 53ae7d2 | 2014-04-17 12:53:16 +0200 | [diff] [blame] | 8 | - in the Web UI under 'Projects' > 'Create Project' |
| 9 | - via the link:rest-api-projects.html#create-project[Create Project] |
| 10 | REST endpoint |
| 11 | - via the link:cmd-create-project.html[create-project] SSH command |
Shawn O. Pearce | 6e75221 | 2009-08-12 12:22:12 -0700 | [diff] [blame] | 12 | |
Edwin Kempin | 53ae7d2 | 2014-04-17 12:53:16 +0200 | [diff] [blame] | 13 | To be able to create new projects the global capability |
| 14 | link:access-control.html#capability_createProject[Create Project] must |
| 15 | be granted. |
Shawn O. Pearce | 6e75221 | 2009-08-12 12:22:12 -0700 | [diff] [blame] | 16 | |
Edwin Kempin | 53ae7d2 | 2014-04-17 12:53:16 +0200 | [diff] [blame] | 17 | In addition, projects can be created link:#manual_project_creation[ |
| 18 | manually]. |
Shawn O. Pearce | 6e75221 | 2009-08-12 12:22:12 -0700 | [diff] [blame] | 19 | |
Edwin Kempin | 53ae7d2 | 2014-04-17 12:53:16 +0200 | [diff] [blame] | 20 | [[manual_project_creation]] |
| 21 | === Manual Project Creation |
Shawn O. Pearce | 6e75221 | 2009-08-12 12:22:12 -0700 | [diff] [blame] | 22 | |
Edwin Kempin | 53ae7d2 | 2014-04-17 12:53:16 +0200 | [diff] [blame] | 23 | . Create a Git repository under `gerrit.basePath`: |
| 24 | + |
Michael Ochmann | b99feab | 2016-07-06 14:10:22 +0200 | [diff] [blame^] | 25 | ---- |
Shawn O. Pearce | 9743d0b | 2009-06-01 10:10:06 -0700 | [diff] [blame] | 26 | git --git-dir=$base_path/new/project.git init |
Michael Ochmann | b99feab | 2016-07-06 14:10:22 +0200 | [diff] [blame^] | 27 | ---- |
Edwin Kempin | 53ae7d2 | 2014-04-17 12:53:16 +0200 | [diff] [blame] | 28 | + |
Shawn O. Pearce | d2b73db | 2009-01-09 11:55:47 -0800 | [diff] [blame] | 29 | [TIP] |
Shawn O. Pearce | 5596823 | 2009-05-08 10:23:27 -0700 | [diff] [blame] | 30 | By tradition the repository directory name should have a `.git` |
| 31 | suffix. |
Edwin Kempin | 53ae7d2 | 2014-04-17 12:53:16 +0200 | [diff] [blame] | 32 | + |
Shawn O. Pearce | d2b73db | 2009-01-09 11:55:47 -0800 | [diff] [blame] | 33 | To also make this repository available over the anonymous git:// |
Shawn O. Pearce | 5596823 | 2009-05-08 10:23:27 -0700 | [diff] [blame] | 34 | protocol, don't forget to create a `git-daemon-export-ok` file: |
Edwin Kempin | 53ae7d2 | 2014-04-17 12:53:16 +0200 | [diff] [blame] | 35 | + |
Michael Ochmann | b99feab | 2016-07-06 14:10:22 +0200 | [diff] [blame^] | 36 | ---- |
Shawn O. Pearce | 9743d0b | 2009-06-01 10:10:06 -0700 | [diff] [blame] | 37 | touch $base_path/new/project.git/git-daemon-export-ok |
Michael Ochmann | b99feab | 2016-07-06 14:10:22 +0200 | [diff] [blame^] | 38 | ---- |
Shawn O. Pearce | d2b73db | 2009-01-09 11:55:47 -0800 | [diff] [blame] | 39 | |
Edwin Kempin | 53ae7d2 | 2014-04-17 12:53:16 +0200 | [diff] [blame] | 40 | . Register Project |
| 41 | + |
Shawn O. Pearce | c756ecf | 2011-06-20 18:49:57 -0700 | [diff] [blame] | 42 | Either restart the server, or flush the `project_list` cache: |
Edwin Kempin | 53ae7d2 | 2014-04-17 12:53:16 +0200 | [diff] [blame] | 43 | + |
Michael Ochmann | b99feab | 2016-07-06 14:10:22 +0200 | [diff] [blame^] | 44 | ---- |
Shawn O. Pearce | c756ecf | 2011-06-20 18:49:57 -0700 | [diff] [blame] | 45 | ssh -p 29418 localhost gerrit flush-caches --cache project_list |
Michael Ochmann | b99feab | 2016-07-06 14:10:22 +0200 | [diff] [blame^] | 46 | ---- |
Shawn O. Pearce | d2b73db | 2009-01-09 11:55:47 -0800 | [diff] [blame] | 47 | |
Edwin Kempin | 7036391 | 2014-04-17 16:53:38 +0200 | [diff] [blame] | 48 | [[project_options]] |
| 49 | == Project Options |
| 50 | |
Shawn O. Pearce | 6e75221 | 2009-08-12 12:22:12 -0700 | [diff] [blame] | 51 | [[submit_type]] |
Edwin Kempin | 7036391 | 2014-04-17 16:53:38 +0200 | [diff] [blame] | 52 | === Submit Type |
Shawn O. Pearce | 97cd0ca | 2009-03-27 16:53:32 -0700 | [diff] [blame] | 53 | |
| 54 | The method Gerrit uses to submit a change to a project can be |
Edwin Kempin | 5819c95 | 2012-12-12 13:07:05 +0100 | [diff] [blame] | 55 | modified by any project owner through the project console, `Projects` > |
Sebastian Schuberth | 424984b | 2016-04-29 09:50:59 +0200 | [diff] [blame] | 56 | `List` > my/project. In general, a submitted change is only merged if all |
| 57 | its dependencies are also submitted, with exceptions documented below. |
| 58 | The following submit types are supported: |
Shawn O. Pearce | 97cd0ca | 2009-03-27 16:53:32 -0700 | [diff] [blame] | 59 | |
Edwin Kempin | eaff6c1 | 2014-04-17 15:23:42 +0200 | [diff] [blame] | 60 | [[fast_forward_only]] |
Shawn O. Pearce | 97cd0ca | 2009-03-27 16:53:32 -0700 | [diff] [blame] | 61 | * Fast Forward Only |
| 62 | + |
Marcus Holl | 7ba3995 | 2014-12-17 14:01:31 +0100 | [diff] [blame] | 63 | With this method no merge commits are produced. All merges must |
Shawn O. Pearce | 97cd0ca | 2009-03-27 16:53:32 -0700 | [diff] [blame] | 64 | be handled on the client, prior to uploading to Gerrit for review. |
| 65 | + |
| 66 | To submit a change, the change must be a strict superset of the |
| 67 | destination branch. That is, the change must already contain the |
| 68 | tip of the destination branch at submit time. |
| 69 | |
Edwin Kempin | eaff6c1 | 2014-04-17 15:23:42 +0200 | [diff] [blame] | 70 | [[merge_if_necessary]] |
Shawn O. Pearce | 97cd0ca | 2009-03-27 16:53:32 -0700 | [diff] [blame] | 71 | * Merge If Necessary |
| 72 | + |
Edwin Kempin | 31740d6 | 2011-10-12 09:27:51 +0200 | [diff] [blame] | 73 | This is the default for a new project. |
Shawn O. Pearce | 97cd0ca | 2009-03-27 16:53:32 -0700 | [diff] [blame] | 74 | + |
| 75 | If the change being submitted is a strict superset of the destination |
| 76 | branch, then the branch is fast-forwarded to the change. If not, |
| 77 | then a merge commit is automatically created. This is identical |
Edwin Kempin | cdb0e00 | 2011-09-08 14:23:30 +0200 | [diff] [blame] | 78 | to the classical `git merge` behavior, or `git merge --ff`. |
Shawn O. Pearce | 97cd0ca | 2009-03-27 16:53:32 -0700 | [diff] [blame] | 79 | |
Edwin Kempin | eaff6c1 | 2014-04-17 15:23:42 +0200 | [diff] [blame] | 80 | [[always_merge]] |
Shawn O. Pearce | 97cd0ca | 2009-03-27 16:53:32 -0700 | [diff] [blame] | 81 | * Always Merge |
| 82 | + |
| 83 | Always produce a merge commit, even if the change is a strict |
| 84 | superset of the destination branch. This is identical to the |
Edwin Kempin | cdb0e00 | 2011-09-08 14:23:30 +0200 | [diff] [blame] | 85 | behavior of `git merge --no-ff`, and may be useful if the |
| 86 | project needs to follow submits with `git log --first-parent`. |
Shawn O. Pearce | 97cd0ca | 2009-03-27 16:53:32 -0700 | [diff] [blame] | 87 | |
Edwin Kempin | eaff6c1 | 2014-04-17 15:23:42 +0200 | [diff] [blame] | 88 | [[cherry_pick]] |
Shawn O. Pearce | 3d17dbd | 2009-03-27 19:32:52 -0700 | [diff] [blame] | 89 | * Cherry Pick |
| 90 | + |
| 91 | Always cherry pick the patch set, ignoring the parent lineage |
| 92 | and instead creating a brand new commit on top of the current |
| 93 | branch head. |
| 94 | + |
| 95 | When cherry picking a change, Gerrit automatically appends onto the |
| 96 | end of the commit message a short summary of the change's approvals, |
| 97 | and a URL link back to the change on the web. The committer header |
| 98 | is also set to the submitter, while the author header retains the |
| 99 | original patch set author. |
Francois Marier | 8748e5e | 2011-04-12 16:00:37 +1200 | [diff] [blame] | 100 | + |
Sebastian Schuberth | 424984b | 2016-04-29 09:50:59 +0200 | [diff] [blame] | 101 | Note that Gerrit ignores dependencies between changes when using this |
| 102 | submit type unless |
| 103 | link:config-gerrit.html#change.submitWholeTopic[`change.submitWholeTopic`] |
| 104 | is enabled and depending changes share the same topic. So generally |
| 105 | submitters must remember to submit changes in the right order when using this |
| 106 | submit type. |
Shawn O. Pearce | 3d17dbd | 2009-03-27 19:32:52 -0700 | [diff] [blame] | 107 | |
Edwin Kempin | 3946212 | 2013-03-27 09:18:19 +0100 | [diff] [blame] | 108 | [[rebase_if_necessary]] |
Edwin Kempin | 00aa4f0 | 2012-09-12 13:38:44 +0200 | [diff] [blame] | 109 | * Rebase If Necessary |
| 110 | + |
| 111 | If the change being submitted is a strict superset of the destination |
| 112 | branch, then the branch is fast-forwarded to the change. If not, |
| 113 | then the change is automatically rebased and then the branch is |
| 114 | fast-forwarded to the change. |
| 115 | |
Edwin Kempin | 37118e7 | 2011-10-12 10:04:47 +0200 | [diff] [blame] | 116 | When Gerrit tries to do a merge, by default the merge will only |
David Pursehouse | 17c051d | 2013-05-14 17:45:00 +0900 | [diff] [blame] | 117 | succeed if there is no path conflict. A path conflict occurs when |
| 118 | the same file has also been changed on the other side of the merge. |
| 119 | |
Edwin Kempin | eaff6c1 | 2014-04-17 15:23:42 +0200 | [diff] [blame] | 120 | [[content_merge]] |
Sebastian Schuberth | 774aac9 | 2015-04-16 13:21:04 +0200 | [diff] [blame] | 121 | If `Allow content merges` is enabled, Gerrit will try |
David Pursehouse | 17c051d | 2013-05-14 17:45:00 +0900 | [diff] [blame] | 122 | to do a content merge when a path conflict occurs. |
Edwin Kempin | 37118e7 | 2011-10-12 10:04:47 +0200 | [diff] [blame] | 123 | |
Edwin Kempin | f2b47e2 | 2014-04-24 13:00:28 +0200 | [diff] [blame] | 124 | [[project-state]] |
Edwin Kempin | 7036391 | 2014-04-17 16:53:38 +0200 | [diff] [blame] | 125 | === State |
| 126 | |
| 127 | This setting defines the state of the project. A project can have the |
| 128 | following states: |
| 129 | |
| 130 | - `Active`: |
| 131 | + |
| 132 | The project is active and users can see and modify the project according |
| 133 | to their access rights on the project. |
| 134 | |
| 135 | - `Read Only`: |
| 136 | + |
| 137 | The project is read only and all modifying operations on it are |
| 138 | disabled. E.g. this means that pushing to this project fails for all |
| 139 | users even if they have push permissions assigned on it. |
| 140 | + |
| 141 | Setting a project to this state is an easy way to temporary close a |
| 142 | project, as you can keep all write access rights in place and they will |
| 143 | become active again as soon as the project state is set back to |
| 144 | `Active`. |
| 145 | + |
| 146 | This state also makes sense if a project was moved to another location. |
| 147 | In this case all new development should happen in the new project and |
| 148 | you want to prevent that somebody accidentally works on the old |
| 149 | project, while keeping the old project around for old references. |
| 150 | |
| 151 | - `Hidden`: |
| 152 | + |
| 153 | The project is hidden and only visible to project owners. Other users |
| 154 | are not able to see the project even if they have read permissions |
| 155 | granted on the project. |
| 156 | |
Deniz Türkoglu | 5277727 | 2014-09-08 17:02:48 +0200 | [diff] [blame] | 157 | === Use target branch when determining new changes to open |
| 158 | |
| 159 | The `create-new-change-for-all-not-in-target` option provides a |
| 160 | convenience for selecting link:user-upload.html#base[the merge base] |
| 161 | by setting it automatically to the target branch's tip so you can |
| 162 | create new changes for all commits not in the target branch. |
| 163 | |
| 164 | This option is disabled if the tip of the push is a merge commit. |
| 165 | |
| 166 | This option also only works if there are no merge commits in the |
| 167 | commit chain, in such cases it fails warning the user that such |
| 168 | pushes can only be performed by manually specifying |
| 169 | link:user-upload.html#base[bases] |
| 170 | |
| 171 | This option is useful if you want to push a change to your personal |
| 172 | branch first and for review to another branch for example. Or in cases |
| 173 | where a commit is already merged into a branch and you want to create |
| 174 | a new open change for that commit on another branch. |
| 175 | |
Edwin Kempin | 1f55622 | 2015-04-22 13:24:39 +0200 | [diff] [blame] | 176 | [[require-change-id]] |
Edwin Kempin | 7036391 | 2014-04-17 16:53:38 +0200 | [diff] [blame] | 177 | === Require Change-Id |
| 178 | |
| 179 | The `Require Change-Id in commit message` option defines whether a |
| 180 | link:user-changeid.html[Change-Id] in the commit message is required |
| 181 | for pushing a commit for review. If this option is set, trying to push |
| 182 | a commit for review that doesn't contain a Change-Id in the commit |
| 183 | message fails with link:error-missing-changeid.html[missing Change-Id |
| 184 | in commit message footer]. |
| 185 | |
| 186 | It is recommended to set this option and use a |
| 187 | link:user-changeid.html#create[commit-msg hook] (or other client side |
| 188 | tooling like EGit) to automatically generate Change-Id's for new |
| 189 | commits. This way the Change-Id is automatically in place when changes |
| 190 | are reworked or rebased and uploading new patch sets gets easy. |
| 191 | |
| 192 | If this option is not set, commits can be uploaded without a Change-Id, |
| 193 | but then users have to remember to copy the assigned Change-Id from the |
| 194 | change screen and insert it manually into the commit message when they |
| 195 | want to upload a second patch set. |
| 196 | |
| 197 | === Maximum Git Object Size Limit |
| 198 | |
| 199 | This option defines the maximum allowed Git object size that |
| 200 | receive-pack will accept. If an object is larger than the given size |
| 201 | the pack-parsing will abort and the push operation will fail. |
| 202 | |
| 203 | With this option users can be prevented from uploading commits that |
| 204 | contain files which are too large. |
| 205 | |
| 206 | Normally the link:config-gerrit.html#receive.maxObjectSizeLimit[maximum |
| 207 | Git object size limit] is configured globally for a Gerrit server. At |
| 208 | the project level, the maximum Git object size limit can be further |
| 209 | reduced, but not extended. The displayed effective limit shows the |
| 210 | maximum Git object size limit that is actually used on the project. |
| 211 | |
| 212 | The defined maximum Git object size limit is inherited by any child |
| 213 | project. |
| 214 | |
| 215 | === Require Signed-off-by |
| 216 | |
| 217 | The `Require Signed-off-by in commit message` option defines whether a |
| 218 | link:user-signedoffby.html[Signed-off-by] line in the commit message is |
| 219 | required for pushing a commit. If this option is set, trying to push a |
| 220 | commit that doesn't contain a Signed-off-by line in the commit message |
| 221 | fails with link:error-not-signed-off-by.html[not Signed-off-by |
| 222 | author/committer/uploader in commit message footer]. |
Shawn O. Pearce | 97cd0ca | 2009-03-27 16:53:32 -0700 | [diff] [blame] | 223 | |
Edwin Kempin | 34f4f88 | 2014-04-22 16:13:18 +0200 | [diff] [blame] | 224 | [[branch-admin]] |
| 225 | == Branch Administration |
Shawn O. Pearce | d2b73db | 2009-01-09 11:55:47 -0800 | [diff] [blame] | 226 | |
Edwin Kempin | 34f4f88 | 2014-04-22 16:13:18 +0200 | [diff] [blame] | 227 | [[branch-creation]] |
| 228 | === Branch Creation |
Shawn O. Pearce | d2b73db | 2009-01-09 11:55:47 -0800 | [diff] [blame] | 229 | |
Edwin Kempin | 34f4f88 | 2014-04-22 16:13:18 +0200 | [diff] [blame] | 230 | There are several ways to create a new branch in a project: |
| 231 | |
| 232 | - in the Web UI under 'Projects' > 'List' > <project> > 'Branches' |
| 233 | - via the link:rest-api-projects.html#create-branch[Create Branch] |
| 234 | REST endpoint |
| 235 | - via the link:cmd-create-branch.html[create-branch] SSH command |
| 236 | - by using a git client to push a commit to a non-existing branch |
| 237 | |
| 238 | To be able to create new branches the user must have the |
| 239 | link:access-control.html#category_create[Create Reference] access |
| 240 | right. In addition, project owners and Gerrit administrators can create |
| 241 | new branches from the Web UI or via REST even without having the |
| 242 | `Create Reference` access right. |
| 243 | |
David Pursehouse | a1d633b | 2014-05-02 17:21:02 +0900 | [diff] [blame] | 244 | When using the Web UI, the REST endpoint or the SSH command it is only |
Edwin Kempin | 34f4f88 | 2014-04-22 16:13:18 +0200 | [diff] [blame] | 245 | possible to create branches on commits that already exist in the |
| 246 | repository. |
| 247 | |
| 248 | If a branch name does not start with `refs/` it is automatically |
| 249 | prefixed with `refs/heads/`. |
| 250 | |
| 251 | The starting revision for a new branch can be any valid SHA-1 |
| 252 | expression, as long as it resolves to a commit. Abbreviated SHA-1s |
| 253 | are not supported. |
| 254 | |
| 255 | [[branch-deletion]] |
| 256 | === Branch Deletion |
| 257 | |
| 258 | There are several ways to delete a branch: |
| 259 | |
| 260 | - in the Web UI under 'Projects' > 'List' > <project> > 'Branches' |
| 261 | - via the link:rest-api-projects.html#delete-branch[Delete Branch] |
| 262 | REST endpoint |
| 263 | - by using a git client to force push nothing to an existing branch |
| 264 | + |
Michael Ochmann | b99feab | 2016-07-06 14:10:22 +0200 | [diff] [blame^] | 265 | ---- |
Edwin Kempin | 34f4f88 | 2014-04-22 16:13:18 +0200 | [diff] [blame] | 266 | $ git push --force origin :refs/heads/<branch-to-delete> |
Michael Ochmann | b99feab | 2016-07-06 14:10:22 +0200 | [diff] [blame^] | 267 | ---- |
Edwin Kempin | 34f4f88 | 2014-04-22 16:13:18 +0200 | [diff] [blame] | 268 | |
| 269 | To be able to delete branches, the user must have the |
| 270 | link:access-control.html#category_push[Push] access right with the |
| 271 | `force` option. In addition, project owners and Gerrit administrators |
| 272 | can delete branches from the Web UI or via REST even without having the |
| 273 | `Force Push` access right. |
| 274 | |
| 275 | [[default-branch]] |
| 276 | === Default Branch |
| 277 | |
| 278 | The default branch of a remote repository is defined by its `HEAD`. |
| 279 | For convenience reasons, when the repository is cloned Git creates a |
| 280 | local branch for this default branch and checks it out. |
| 281 | |
| 282 | Project owners can set `HEAD` |
| 283 | |
| 284 | - in the Web UI under 'Projects' > 'List' > <project> > 'Branches' or |
| 285 | - via the link:rest-api-projects.html#set-head[Set HEAD] REST endpoint |
| 286 | |
Shawn O. Pearce | 5500e69 | 2009-05-28 15:55:01 -0700 | [diff] [blame] | 287 | |
| 288 | GERRIT |
| 289 | ------ |
| 290 | Part of link:index.html[Gerrit Code Review] |
Yuxuan 'fishy' Wang | 99cb68d | 2013-10-31 17:26:00 -0700 | [diff] [blame] | 291 | |
| 292 | SEARCHBOX |
| 293 | --------- |