blob: cb12ec92be31e59282bc1afba34d53267244960d [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 Kempin53ae7d22014-04-17 12:53:16 +02003== Project Creation
Shawn O. Pearce6e752212009-08-12 12:22:12 -07004
Edwin Kempin53ae7d22014-04-17 12:53:16 +02005There are several ways to create a new project in Gerrit:
Shawn O. Pearce6e752212009-08-12 12:22:12 -07006
Edwin Kempin53ae7d22014-04-17 12:53:16 +02007- 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. Pearce6e752212009-08-12 12:22:12 -070011
Edwin Kempin53ae7d22014-04-17 12:53:16 +020012To be able to create new projects the global capability
13link:access-control.html#capability_createProject[Create Project] must
14be granted.
Shawn O. Pearce6e752212009-08-12 12:22:12 -070015
Edwin Kempin53ae7d22014-04-17 12:53:16 +020016In addition, projects can be created link:#manual_project_creation[
17manually].
Shawn O. Pearce6e752212009-08-12 12:22:12 -070018
Edwin Kempin53ae7d22014-04-17 12:53:16 +020019[[manual_project_creation]]
20=== Manual Project Creation
Shawn O. Pearce6e752212009-08-12 12:22:12 -070021
Edwin Kempin53ae7d22014-04-17 12:53:16 +020022. Create a Git repository under `gerrit.basePath`:
23+
Shawn O. Pearced2b73db2009-01-09 11:55:47 -080024====
Shawn O. Pearce9743d0b2009-06-01 10:10:06 -070025 git --git-dir=$base_path/new/project.git init
Shawn O. Pearced2b73db2009-01-09 11:55:47 -080026====
Edwin Kempin53ae7d22014-04-17 12:53:16 +020027+
Shawn O. Pearced2b73db2009-01-09 11:55:47 -080028[TIP]
Shawn O. Pearce55968232009-05-08 10:23:27 -070029By tradition the repository directory name should have a `.git`
30suffix.
Edwin Kempin53ae7d22014-04-17 12:53:16 +020031+
Shawn O. Pearced2b73db2009-01-09 11:55:47 -080032To also make this repository available over the anonymous git://
Shawn O. Pearce55968232009-05-08 10:23:27 -070033protocol, don't forget to create a `git-daemon-export-ok` file:
Edwin Kempin53ae7d22014-04-17 12:53:16 +020034+
Shawn O. Pearced2b73db2009-01-09 11:55:47 -080035====
Shawn O. Pearce9743d0b2009-06-01 10:10:06 -070036 touch $base_path/new/project.git/git-daemon-export-ok
Shawn O. Pearced2b73db2009-01-09 11:55:47 -080037====
38
Edwin Kempin53ae7d22014-04-17 12:53:16 +020039. Register Project
40+
Shawn O. Pearcec756ecf2011-06-20 18:49:57 -070041Either restart the server, or flush the `project_list` cache:
Edwin Kempin53ae7d22014-04-17 12:53:16 +020042+
Shawn O. Pearced2b73db2009-01-09 11:55:47 -080043====
Shawn O. Pearcec756ecf2011-06-20 18:49:57 -070044 ssh -p 29418 localhost gerrit flush-caches --cache project_list
Shawn O. Pearced2b73db2009-01-09 11:55:47 -080045====
46
Edwin Kempin70363912014-04-17 16:53:38 +020047[[project_options]]
48== Project Options
49
Shawn O. Pearce6e752212009-08-12 12:22:12 -070050[[submit_type]]
Edwin Kempin70363912014-04-17 16:53:38 +020051=== Submit Type
Shawn O. Pearce97cd0ca2009-03-27 16:53:32 -070052
53The method Gerrit uses to submit a change to a project can be
Edwin Kempin5819c952012-12-12 13:07:05 +010054modified by any project owner through the project console, `Projects` >
55`List` > my/project. The following methods are supported:
Shawn O. Pearce97cd0ca2009-03-27 16:53:32 -070056
Edwin Kempineaff6c12014-04-17 15:23:42 +020057[[fast_forward_only]]
Shawn O. Pearce97cd0ca2009-03-27 16:53:32 -070058* Fast Forward Only
59+
60This method produces a strictly linear history. All merges must
61be handled on the client, prior to uploading to Gerrit for review.
62+
63To submit a change, the change must be a strict superset of the
64destination branch. That is, the change must already contain the
65tip of the destination branch at submit time.
66
Edwin Kempineaff6c12014-04-17 15:23:42 +020067[[merge_if_necessary]]
Shawn O. Pearce97cd0ca2009-03-27 16:53:32 -070068* Merge If Necessary
69+
Edwin Kempin31740d62011-10-12 09:27:51 +020070This is the default for a new project.
Shawn O. Pearce97cd0ca2009-03-27 16:53:32 -070071+
72If the change being submitted is a strict superset of the destination
73branch, then the branch is fast-forwarded to the change. If not,
74then a merge commit is automatically created. This is identical
Edwin Kempincdb0e002011-09-08 14:23:30 +020075to the classical `git merge` behavior, or `git merge --ff`.
Shawn O. Pearce97cd0ca2009-03-27 16:53:32 -070076
Edwin Kempineaff6c12014-04-17 15:23:42 +020077[[always_merge]]
Shawn O. Pearce97cd0ca2009-03-27 16:53:32 -070078* Always Merge
79+
80Always produce a merge commit, even if the change is a strict
81superset of the destination branch. This is identical to the
Edwin Kempincdb0e002011-09-08 14:23:30 +020082behavior of `git merge --no-ff`, and may be useful if the
83project needs to follow submits with `git log --first-parent`.
Shawn O. Pearce97cd0ca2009-03-27 16:53:32 -070084
Edwin Kempineaff6c12014-04-17 15:23:42 +020085[[cherry_pick]]
Shawn O. Pearce3d17dbd2009-03-27 19:32:52 -070086* Cherry Pick
87+
88Always cherry pick the patch set, ignoring the parent lineage
89and instead creating a brand new commit on top of the current
90branch head.
91+
92When cherry picking a change, Gerrit automatically appends onto the
93end of the commit message a short summary of the change's approvals,
94and a URL link back to the change on the web. The committer header
95is also set to the submitter, while the author header retains the
96original patch set author.
Francois Marier8748e5e2011-04-12 16:00:37 +120097+
98Note that Gerrit ignores patch set dependencies when operating in
99cherry-pick mode. Submitters must remember to submit changes in
100the right order since inter-change dependencies will not be
101enforced for them.
Shawn O. Pearce3d17dbd2009-03-27 19:32:52 -0700102
Edwin Kempin39462122013-03-27 09:18:19 +0100103[[rebase_if_necessary]]
Edwin Kempin00aa4f02012-09-12 13:38:44 +0200104* Rebase If Necessary
105+
106If the change being submitted is a strict superset of the destination
107branch, then the branch is fast-forwarded to the change. If not,
108then the change is automatically rebased and then the branch is
109fast-forwarded to the change.
110
Edwin Kempin37118e72011-10-12 10:04:47 +0200111When Gerrit tries to do a merge, by default the merge will only
David Pursehouse17c051d2013-05-14 17:45:00 +0900112succeed if there is no path conflict. A path conflict occurs when
113the same file has also been changed on the other side of the merge.
114
Edwin Kempineaff6c12014-04-17 15:23:42 +0200115[[content_merge]]
David Pursehouse17c051d2013-05-14 17:45:00 +0900116If `Automatically resolve conflicts` is enabled, Gerrit will try
117to do a content merge when a path conflict occurs.
Edwin Kempin37118e72011-10-12 10:04:47 +0200118
Edwin Kempin70363912014-04-17 16:53:38 +0200119=== State
120
121This setting defines the state of the project. A project can have the
122following states:
123
124- `Active`:
125+
126The project is active and users can see and modify the project according
127to their access rights on the project.
128
129- `Read Only`:
130+
131The project is read only and all modifying operations on it are
132disabled. E.g. this means that pushing to this project fails for all
133users even if they have push permissions assigned on it.
134+
135Setting a project to this state is an easy way to temporary close a
136project, as you can keep all write access rights in place and they will
137become active again as soon as the project state is set back to
138`Active`.
139+
140This state also makes sense if a project was moved to another location.
141In this case all new development should happen in the new project and
142you want to prevent that somebody accidentally works on the old
143project, while keeping the old project around for old references.
144
145- `Hidden`:
146+
147The project is hidden and only visible to project owners. Other users
148are not able to see the project even if they have read permissions
149granted on the project.
150
151=== Require Change-Id
152
153The `Require Change-Id in commit message` option defines whether a
154link:user-changeid.html[Change-Id] in the commit message is required
155for pushing a commit for review. If this option is set, trying to push
156a commit for review that doesn't contain a Change-Id in the commit
157message fails with link:error-missing-changeid.html[missing Change-Id
158in commit message footer].
159
160It is recommended to set this option and use a
161link:user-changeid.html#create[commit-msg hook] (or other client side
162tooling like EGit) to automatically generate Change-Id's for new
163commits. This way the Change-Id is automatically in place when changes
164are reworked or rebased and uploading new patch sets gets easy.
165
166If this option is not set, commits can be uploaded without a Change-Id,
167but then users have to remember to copy the assigned Change-Id from the
168change screen and insert it manually into the commit message when they
169want to upload a second patch set.
170
171=== Maximum Git Object Size Limit
172
173This option defines the maximum allowed Git object size that
174receive-pack will accept. If an object is larger than the given size
175the pack-parsing will abort and the push operation will fail.
176
177With this option users can be prevented from uploading commits that
178contain files which are too large.
179
180Normally the link:config-gerrit.html#receive.maxObjectSizeLimit[maximum
181Git object size limit] is configured globally for a Gerrit server. At
182the project level, the maximum Git object size limit can be further
183reduced, but not extended. The displayed effective limit shows the
184maximum Git object size limit that is actually used on the project.
185
186The defined maximum Git object size limit is inherited by any child
187project.
188
189=== Require Signed-off-by
190
191The `Require Signed-off-by in commit message` option defines whether a
192link:user-signedoffby.html[Signed-off-by] line in the commit message is
193required for pushing a commit. If this option is set, trying to push a
194commit that doesn't contain a Signed-off-by line in the commit message
195fails with link:error-not-signed-off-by.html[not Signed-off-by
196author/committer/uploader in commit message footer].
Shawn O. Pearce97cd0ca2009-03-27 16:53:32 -0700197
Edwin Kempin34f4f882014-04-22 16:13:18 +0200198[[branch-admin]]
199== Branch Administration
Shawn O. Pearced2b73db2009-01-09 11:55:47 -0800200
Edwin Kempin34f4f882014-04-22 16:13:18 +0200201[[branch-creation]]
202=== Branch Creation
Shawn O. Pearced2b73db2009-01-09 11:55:47 -0800203
Edwin Kempin34f4f882014-04-22 16:13:18 +0200204There 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
212To be able to create new branches the user must have the
213link:access-control.html#category_create[Create Reference] access
214right. In addition, project owners and Gerrit administrators can create
215new branches from the Web UI or via REST even without having the
216`Create Reference` access right.
217
218When using the WebUI, the REST endpoint or the SSH command it is only
219possible to create branches on commits that already exist in the
220repository.
221
222If a branch name does not start with `refs/` it is automatically
223prefixed with `refs/heads/`.
224
225The starting revision for a new branch can be any valid SHA-1
226expression, as long as it resolves to a commit. Abbreviated SHA-1s
227are not supported.
228
229[[branch-deletion]]
230=== Branch Deletion
231
232There 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
243To be able to delete branches, the user must have the
244link:access-control.html#category_push[Push] access right with the
245`force` option. In addition, project owners and Gerrit administrators
246can 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
252The default branch of a remote repository is defined by its `HEAD`.
253For convenience reasons, when the repository is cloned Git creates a
254local branch for this default branch and checks it out.
255
256Project 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. Pearce5500e692009-05-28 15:55:01 -0700261
262GERRIT
263------
264Part of link:index.html[Gerrit Code Review]
Yuxuan 'fishy' Wang99cb68d2013-10-31 17:26:00 -0700265
266SEARCHBOX
267---------