blob: 23030a4f8694ab539a1afa41fc0b5f09b6aa0eda [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
Changcheng Xiao5ecb6422019-01-15 17:17:04 +010051See details at link:config-project-config.html#project-section[project section].
Edwin Kempin70363912014-04-17 16:53:38 +020052
Edwin Kempin34f4f882014-04-22 16:13:18 +020053[[branch-admin]]
54== Branch Administration
Shawn O. Pearced2b73db2009-01-09 11:55:47 -080055
Edwin Kempin34f4f882014-04-22 16:13:18 +020056[[branch-creation]]
57=== Branch Creation
Shawn O. Pearced2b73db2009-01-09 11:55:47 -080058
Edwin Kempin34f4f882014-04-22 16:13:18 +020059There are several ways to create a new branch in a project:
60
61- in the Web UI under 'Projects' > 'List' > <project> > 'Branches'
62- via the link:rest-api-projects.html#create-branch[Create Branch]
63 REST endpoint
64- via the link:cmd-create-branch.html[create-branch] SSH command
65- by using a git client to push a commit to a non-existing branch
66
67To be able to create new branches the user must have the
68link:access-control.html#category_create[Create Reference] access
Hugo Arès5187d672018-03-19 13:04:01 -040069right.
Edwin Kempin34f4f882014-04-22 16:13:18 +020070
David Pursehousea1d633b2014-05-02 17:21:02 +090071When using the Web UI, the REST endpoint or the SSH command it is only
Edwin Kempin34f4f882014-04-22 16:13:18 +020072possible to create branches on commits that already exist in the
73repository.
74
75If a branch name does not start with `refs/` it is automatically
76prefixed with `refs/heads/`.
77
78The starting revision for a new branch can be any valid SHA-1
79expression, as long as it resolves to a commit. Abbreviated SHA-1s
80are not supported.
81
82[[branch-deletion]]
83=== Branch Deletion
84
85There are several ways to delete a branch:
86
87- in the Web UI under 'Projects' > 'List' > <project> > 'Branches'
88- via the link:rest-api-projects.html#delete-branch[Delete Branch]
89 REST endpoint
Gert van Dijk8c5e33c2017-10-19 22:38:06 +020090- by using a git client
91+
92----
93 $ git push origin --delete refs/heads/<branch-to-delete>
94----
95+
96another method, by force pushing nothing to an existing branch:
Edwin Kempin34f4f882014-04-22 16:13:18 +020097+
Michael Ochmannb99feab2016-07-06 14:10:22 +020098----
Edwin Kempin34f4f882014-04-22 16:13:18 +020099 $ git push --force origin :refs/heads/<branch-to-delete>
Michael Ochmannb99feab2016-07-06 14:10:22 +0200100----
Edwin Kempin34f4f882014-04-22 16:13:18 +0200101
102To be able to delete branches, the user must have the
Gert van Dijk8c5e33c2017-10-19 22:38:06 +0200103link:access-control.html#category_delete[Delete Reference] or the
Edwin Kempin34f4f882014-04-22 16:13:18 +0200104link:access-control.html#category_push[Push] access right with the
Hugo Arès5187d672018-03-19 13:04:01 -0400105`force` option.
Edwin Kempin34f4f882014-04-22 16:13:18 +0200106
107[[default-branch]]
108=== Default Branch
109
110The default branch of a remote repository is defined by its `HEAD`.
111For convenience reasons, when the repository is cloned Git creates a
112local branch for this default branch and checks it out.
113
114Project owners can set `HEAD`
115
116- in the Web UI under 'Projects' > 'List' > <project> > 'Branches' or
117- via the link:rest-api-projects.html#set-head[Set HEAD] REST endpoint
118
Shawn O. Pearce5500e692009-05-28 15:55:01 -0700119
120GERRIT
121------
122Part of link:index.html[Gerrit Code Review]
Yuxuan 'fishy' Wang99cb68d2013-10-31 17:26:00 -0700123
124SEARCHBOX
125---------