blob: 2d3fd6609beca23c6b9efe36fadd074ab03ccfdd [file] [log] [blame]
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -08001= Gerrit Code Review - Project Configuration
Shawn O. Pearced2b73db2009-01-09 11:55:47 -08002
Edwin Kempinf2b47e22014-04-24 13:00:28 +02003[[project-creation]]
Edwin Kempin53ae7d22014-04-17 12:53:16 +02004== Project Creation
Shawn O. Pearce6e752212009-08-12 12:22:12 -07005
Edwin Kempin53ae7d22014-04-17 12:53:16 +02006There are several ways to create a new project in Gerrit:
Shawn O. Pearce6e752212009-08-12 12:22:12 -07007
Edwin Kempin53ae7d22014-04-17 12:53:16 +02008- 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. Pearce6e752212009-08-12 12:22:12 -070012
Edwin Kempin53ae7d22014-04-17 12:53:16 +020013To be able to create new projects the global capability
14link:access-control.html#capability_createProject[Create Project] must
15be granted.
Shawn O. Pearce6e752212009-08-12 12:22:12 -070016
Edwin Kempin53ae7d22014-04-17 12:53:16 +020017In addition, projects can be created link:#manual_project_creation[
18manually].
Shawn O. Pearce6e752212009-08-12 12:22:12 -070019
Edwin Kempin53ae7d22014-04-17 12:53:16 +020020[[manual_project_creation]]
21=== Manual Project Creation
Shawn O. Pearce6e752212009-08-12 12:22:12 -070022
Edwin Kempin53ae7d22014-04-17 12:53:16 +020023. Create a Git repository under `gerrit.basePath`:
24+
Michael Ochmannb99feab2016-07-06 14:10:22 +020025----
Shawn O. Pearce9743d0b2009-06-01 10:10:06 -070026 git --git-dir=$base_path/new/project.git init
Michael Ochmannb99feab2016-07-06 14:10:22 +020027----
Edwin Kempin53ae7d22014-04-17 12:53:16 +020028+
Shawn O. Pearced2b73db2009-01-09 11:55:47 -080029[TIP]
Shawn O. Pearce55968232009-05-08 10:23:27 -070030By tradition the repository directory name should have a `.git`
31suffix.
Edwin Kempin53ae7d22014-04-17 12:53:16 +020032+
Shawn O. Pearced2b73db2009-01-09 11:55:47 -080033To also make this repository available over the anonymous git://
Shawn O. Pearce55968232009-05-08 10:23:27 -070034protocol, don't forget to create a `git-daemon-export-ok` file:
Edwin Kempin53ae7d22014-04-17 12:53:16 +020035+
Michael Ochmannb99feab2016-07-06 14:10:22 +020036----
Shawn O. Pearce9743d0b2009-06-01 10:10:06 -070037 touch $base_path/new/project.git/git-daemon-export-ok
Michael Ochmannb99feab2016-07-06 14:10:22 +020038----
Shawn O. Pearced2b73db2009-01-09 11:55:47 -080039
Edwin Kempin53ae7d22014-04-17 12:53:16 +020040. Register Project
41+
Shawn O. Pearcec756ecf2011-06-20 18:49:57 -070042Either restart the server, or flush the `project_list` cache:
Edwin Kempin53ae7d22014-04-17 12:53:16 +020043+
Michael Ochmannb99feab2016-07-06 14:10:22 +020044----
Shawn O. Pearcec756ecf2011-06-20 18:49:57 -070045 ssh -p 29418 localhost gerrit flush-caches --cache project_list
Michael Ochmannb99feab2016-07-06 14:10:22 +020046----
Shawn O. Pearced2b73db2009-01-09 11:55:47 -080047
Edwin Kempin70363912014-04-17 16:53:38 +020048[[project_options]]
49== Project Options
50
Shawn O. Pearce6e752212009-08-12 12:22:12 -070051[[submit_type]]
Edwin Kempin70363912014-04-17 16:53:38 +020052=== Submit Type
Shawn O. Pearce97cd0ca2009-03-27 16:53:32 -070053
54The method Gerrit uses to submit a change to a project can be
Edwin Kempin5819c952012-12-12 13:07:05 +010055modified by any project owner through the project console, `Projects` >
Sebastian Schuberth424984b2016-04-29 09:50:59 +020056`List` > my/project. In general, a submitted change is only merged if all
57its dependencies are also submitted, with exceptions documented below.
58The following submit types are supported:
Shawn O. Pearce97cd0ca2009-03-27 16:53:32 -070059
Edwin Kempineaff6c12014-04-17 15:23:42 +020060[[fast_forward_only]]
Shawn O. Pearce97cd0ca2009-03-27 16:53:32 -070061* Fast Forward Only
62+
Marcus Holl7ba39952014-12-17 14:01:31 +010063With this method no merge commits are produced. All merges must
Shawn O. Pearce97cd0ca2009-03-27 16:53:32 -070064be handled on the client, prior to uploading to Gerrit for review.
65+
66To submit a change, the change must be a strict superset of the
67destination branch. That is, the change must already contain the
68tip of the destination branch at submit time.
69
Edwin Kempineaff6c12014-04-17 15:23:42 +020070[[merge_if_necessary]]
Shawn O. Pearce97cd0ca2009-03-27 16:53:32 -070071* Merge If Necessary
72+
Edwin Kempin31740d62011-10-12 09:27:51 +020073This is the default for a new project.
Shawn O. Pearce97cd0ca2009-03-27 16:53:32 -070074+
75If the change being submitted is a strict superset of the destination
76branch, then the branch is fast-forwarded to the change. If not,
77then a merge commit is automatically created. This is identical
Edwin Kempincdb0e002011-09-08 14:23:30 +020078to the classical `git merge` behavior, or `git merge --ff`.
Shawn O. Pearce97cd0ca2009-03-27 16:53:32 -070079
Edwin Kempineaff6c12014-04-17 15:23:42 +020080[[always_merge]]
Shawn O. Pearce97cd0ca2009-03-27 16:53:32 -070081* Always Merge
82+
83Always produce a merge commit, even if the change is a strict
84superset of the destination branch. This is identical to the
Edwin Kempincdb0e002011-09-08 14:23:30 +020085behavior of `git merge --no-ff`, and may be useful if the
86project needs to follow submits with `git log --first-parent`.
Shawn O. Pearce97cd0ca2009-03-27 16:53:32 -070087
Edwin Kempineaff6c12014-04-17 15:23:42 +020088[[cherry_pick]]
Shawn O. Pearce3d17dbd2009-03-27 19:32:52 -070089* Cherry Pick
90+
91Always cherry pick the patch set, ignoring the parent lineage
92and instead creating a brand new commit on top of the current
93branch head.
94+
95When cherry picking a change, Gerrit automatically appends onto the
96end of the commit message a short summary of the change's approvals,
97and a URL link back to the change on the web. The committer header
98is also set to the submitter, while the author header retains the
99original patch set author.
Francois Marier8748e5e2011-04-12 16:00:37 +1200100+
Sebastian Schuberth424984b2016-04-29 09:50:59 +0200101Note that Gerrit ignores dependencies between changes when using this
102submit type unless
103link:config-gerrit.html#change.submitWholeTopic[`change.submitWholeTopic`]
104is enabled and depending changes share the same topic. So generally
105submitters must remember to submit changes in the right order when using this
Andrii Shyshkalov7fe45162016-11-22 12:30:19 +0100106submit type. If all you want is extra information in the commit message,
107consider using the Rebase Always submit strategy.
Shawn O. Pearce3d17dbd2009-03-27 19:32:52 -0700108
Edwin Kempin39462122013-03-27 09:18:19 +0100109[[rebase_if_necessary]]
Edwin Kempin00aa4f02012-09-12 13:38:44 +0200110* Rebase If Necessary
111+
112If the change being submitted is a strict superset of the destination
113branch, then the branch is fast-forwarded to the change. If not,
114then the change is automatically rebased and then the branch is
115fast-forwarded to the change.
116
Edwin Kempin37118e72011-10-12 10:04:47 +0200117When Gerrit tries to do a merge, by default the merge will only
David Pursehouse17c051d2013-05-14 17:45:00 +0900118succeed if there is no path conflict. A path conflict occurs when
119the same file has also been changed on the other side of the merge.
120
Andrii Shyshkalova11e63d2016-10-21 15:19:26 +0200121[[rebase_always]]
122* Rebase Always
123+
Andrii Shyshkalov7fe45162016-11-22 12:30:19 +0100124Basically, the same as Rebase If Necessary, but it creates a new patchset even
125if fast forward is possible AND like Cherry Pick it ensures footers such as
126Change-Id, Reviewed-On, and others are present in resulting commit that is
127merged.
128
129Thus, Rebase Always can be considered similar to Cherry Pick, but with
Andrii Shyshkalova11e63d2016-10-21 15:19:26 +0200130the important distinction that Rebase Always does not ignore dependencies.
131
Edwin Kempineaff6c12014-04-17 15:23:42 +0200132[[content_merge]]
Sebastian Schuberth774aac92015-04-16 13:21:04 +0200133If `Allow content merges` is enabled, Gerrit will try
David Pursehouse17c051d2013-05-14 17:45:00 +0900134to do a content merge when a path conflict occurs.
Edwin Kempin37118e72011-10-12 10:04:47 +0200135
Edwin Kempinf2b47e22014-04-24 13:00:28 +0200136[[project-state]]
Edwin Kempin70363912014-04-17 16:53:38 +0200137=== State
138
139This setting defines the state of the project. A project can have the
140following states:
141
142- `Active`:
143+
144The project is active and users can see and modify the project according
145to their access rights on the project.
146
147- `Read Only`:
148+
149The project is read only and all modifying operations on it are
150disabled. E.g. this means that pushing to this project fails for all
151users even if they have push permissions assigned on it.
152+
153Setting a project to this state is an easy way to temporary close a
154project, as you can keep all write access rights in place and they will
155become active again as soon as the project state is set back to
156`Active`.
157+
158This state also makes sense if a project was moved to another location.
159In this case all new development should happen in the new project and
160you want to prevent that somebody accidentally works on the old
161project, while keeping the old project around for old references.
162
163- `Hidden`:
164+
165The project is hidden and only visible to project owners. Other users
166are not able to see the project even if they have read permissions
167granted on the project.
168
Deniz Türkoglu52777272014-09-08 17:02:48 +0200169=== Use target branch when determining new changes to open
170
171The `create-new-change-for-all-not-in-target` option provides a
172convenience for selecting link:user-upload.html#base[the merge base]
173by setting it automatically to the target branch's tip so you can
174create new changes for all commits not in the target branch.
175
176This option is disabled if the tip of the push is a merge commit.
177
178This option also only works if there are no merge commits in the
179commit chain, in such cases it fails warning the user that such
180pushes can only be performed by manually specifying
181link:user-upload.html#base[bases]
182
183This option is useful if you want to push a change to your personal
184branch first and for review to another branch for example. Or in cases
185where a commit is already merged into a branch and you want to create
186a new open change for that commit on another branch.
187
Edwin Kempin1f556222015-04-22 13:24:39 +0200188[[require-change-id]]
Edwin Kempin70363912014-04-17 16:53:38 +0200189=== Require Change-Id
190
191The `Require Change-Id in commit message` option defines whether a
192link:user-changeid.html[Change-Id] in the commit message is required
193for pushing a commit for review. If this option is set, trying to push
194a commit for review that doesn't contain a Change-Id in the commit
195message fails with link:error-missing-changeid.html[missing Change-Id
196in commit message footer].
197
198It is recommended to set this option and use a
199link:user-changeid.html#create[commit-msg hook] (or other client side
200tooling like EGit) to automatically generate Change-Id's for new
201commits. This way the Change-Id is automatically in place when changes
202are reworked or rebased and uploading new patch sets gets easy.
203
204If this option is not set, commits can be uploaded without a Change-Id,
205but then users have to remember to copy the assigned Change-Id from the
206change screen and insert it manually into the commit message when they
207want to upload a second patch set.
208
209=== Maximum Git Object Size Limit
210
211This option defines the maximum allowed Git object size that
212receive-pack will accept. If an object is larger than the given size
213the pack-parsing will abort and the push operation will fail.
214
215With this option users can be prevented from uploading commits that
216contain files which are too large.
217
218Normally the link:config-gerrit.html#receive.maxObjectSizeLimit[maximum
219Git object size limit] is configured globally for a Gerrit server. At
220the project level, the maximum Git object size limit can be further
221reduced, but not extended. The displayed effective limit shows the
222maximum Git object size limit that is actually used on the project.
223
224The defined maximum Git object size limit is inherited by any child
225project.
226
227=== Require Signed-off-by
228
229The `Require Signed-off-by in commit message` option defines whether a
230link:user-signedoffby.html[Signed-off-by] line in the commit message is
231required for pushing a commit. If this option is set, trying to push a
232commit that doesn't contain a Signed-off-by line in the commit message
233fails with link:error-not-signed-off-by.html[not Signed-off-by
234author/committer/uploader in commit message footer].
Shawn O. Pearce97cd0ca2009-03-27 16:53:32 -0700235
Edwin Kempin34f4f882014-04-22 16:13:18 +0200236[[branch-admin]]
237== Branch Administration
Shawn O. Pearced2b73db2009-01-09 11:55:47 -0800238
Edwin Kempin34f4f882014-04-22 16:13:18 +0200239[[branch-creation]]
240=== Branch Creation
Shawn O. Pearced2b73db2009-01-09 11:55:47 -0800241
Edwin Kempin34f4f882014-04-22 16:13:18 +0200242There are several ways to create a new branch in a project:
243
244- in the Web UI under 'Projects' > 'List' > <project> > 'Branches'
245- via the link:rest-api-projects.html#create-branch[Create Branch]
246 REST endpoint
247- via the link:cmd-create-branch.html[create-branch] SSH command
248- by using a git client to push a commit to a non-existing branch
249
250To be able to create new branches the user must have the
251link:access-control.html#category_create[Create Reference] access
252right. In addition, project owners and Gerrit administrators can create
253new branches from the Web UI or via REST even without having the
254`Create Reference` access right.
255
David Pursehousea1d633b2014-05-02 17:21:02 +0900256When using the Web UI, the REST endpoint or the SSH command it is only
Edwin Kempin34f4f882014-04-22 16:13:18 +0200257possible to create branches on commits that already exist in the
258repository.
259
260If a branch name does not start with `refs/` it is automatically
261prefixed with `refs/heads/`.
262
263The starting revision for a new branch can be any valid SHA-1
264expression, as long as it resolves to a commit. Abbreviated SHA-1s
265are not supported.
266
267[[branch-deletion]]
268=== Branch Deletion
269
270There are several ways to delete a branch:
271
272- in the Web UI under 'Projects' > 'List' > <project> > 'Branches'
273- via the link:rest-api-projects.html#delete-branch[Delete Branch]
274 REST endpoint
Gert van Dijk8c5e33c2017-10-19 22:38:06 +0200275- by using a git client
276+
277----
278 $ git push origin --delete refs/heads/<branch-to-delete>
279----
280+
281another method, by force pushing nothing to an existing branch:
Edwin Kempin34f4f882014-04-22 16:13:18 +0200282+
Michael Ochmannb99feab2016-07-06 14:10:22 +0200283----
Edwin Kempin34f4f882014-04-22 16:13:18 +0200284 $ git push --force origin :refs/heads/<branch-to-delete>
Michael Ochmannb99feab2016-07-06 14:10:22 +0200285----
Edwin Kempin34f4f882014-04-22 16:13:18 +0200286
287To be able to delete branches, the user must have the
Gert van Dijk8c5e33c2017-10-19 22:38:06 +0200288link:access-control.html#category_delete[Delete Reference] or the
Edwin Kempin34f4f882014-04-22 16:13:18 +0200289link:access-control.html#category_push[Push] access right with the
290`force` option. In addition, project owners and Gerrit administrators
291can delete branches from the Web UI or via REST even without having the
292`Force Push` access right.
293
294[[default-branch]]
295=== Default Branch
296
297The default branch of a remote repository is defined by its `HEAD`.
298For convenience reasons, when the repository is cloned Git creates a
299local branch for this default branch and checks it out.
300
301Project owners can set `HEAD`
302
303- in the Web UI under 'Projects' > 'List' > <project> > 'Branches' or
304- via the link:rest-api-projects.html#set-head[Set HEAD] REST endpoint
305
Shawn O. Pearce5500e692009-05-28 15:55:01 -0700306
307GERRIT
308------
309Part of link:index.html[Gerrit Code Review]
Yuxuan 'fishy' Wang99cb68d2013-10-31 17:26:00 -0700310
311SEARCHBOX
312---------