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