Branches and remotes
Publish a repository to the server
5 min read
A repository created on your machine doesn't exist on the server yet. Publish repository does it all at once: it creates the project on the registered GitLab or GitHub, adds the remote and pushes, without opening the browser.
You need the server registered with a token (or an OAuth login) in Git servers (see Git servers).
- The REMOTE section of a repository without a remote: the Publish to server… button.
- The Push button in a repository without a remote, when there's a GitLab or GitHub registered with a token.
- Palette (Ctrl+P): "Publish repository to server…" (detail: "Creates the project on GitLab or GitHub, adds the remote and pushes").
- Open Publish repository. The dialog explains: "Creates the project on the server, adds the remote and pushes."
- In Server, choose the GitLab or GitHub (the list shows
host (GitLab)orhost (GitHub)). The last server used comes selected. - In Group or account (on GitHub, Account or organization), choose where the project will live. Your account shows up as "ana (your account)". Groups where you can't create projects show up disabled, like "Plataforma (not allowed to create)".
- In Project name, check the name. It comes from the folder's name.
- On GitLab, check the Path (the path in the project's URL). It follows the name until you edit it.
- If you want, fill in Description (optional).
- In Visibility, choose Private, Internal or Public. The options the group doesn't allow are disabled.
- In Remote name, leave
originor change it. In Remote URL, choose HTTPS or SSH. - In After creating, choose what to send (see the options below).
- Check the summary, for example "Creates equipe/app on gitlab.exemplo.com (Private). Adds the remote origin. Pushes main to origin and sets the upstream."
- Click Publish. The button shows "Checking the push…": before the project is created, the push that's about to happen goes through the same checks as any push (see below). If one of them finds something, the publish window gets out of the way and the usual Before pushing dialog shows up; when it closes, the window comes back as it was. If you give up in the dialog, nothing is created on the server.
- Then the button shows "Creating the project…" and "Pushing…".
- At the end, "Repository published to equipe/app (gitlab.exemplo.com)." shows up, with Open in browser.
| Option | What it does | Default |
|---|---|---|
| Server | A GitLab or GitHub registered with a token. | the last one used |
| Group or account / Account or organization | Where the project is created. | the first one where you can create |
| Project name | The project's display name. On GitHub, it's also the name in the URL. | the folder's name |
| Path (GitLab only) | The path in the project's URL. | derived from the name |
| Description (optional) | The project's description on the server. | empty |
| Visibility | Private: only people you give access to can see it. Internal: anyone with an account on the server can see it. Public: anyone can see it, even without an account. | Private |
| Remote name | The nickname of the added remote. | origin (if it already exists, the service's name, such as gitlab) |
| Remote URL | Use the created project's HTTPS or SSH URL. | HTTPS |
| After creating | Push main and set the upstream, Push all branches and tags or Only add the remote, without pushing. | the push of the current branch |
With a detached HEAD, the first option becomes "Push the current branch (no branch: detached HEAD)" and is unavailable; the push of all branches applies. In a repository with no commits, the project is created and the remote added, without a push: "The repository has no commits yet: the project is created and the remote added, without a push."
The publish push is a push like any other, and goes through the same checks: secrets in the commits, protected branch, push rules and the company policy (see Checks). They run before the project is created, so that a secret doesn't end up in a freshly created project.
- Since the remote doesn't exist yet, the secrets scan looks at all the branch's commits, which is what the first push takes.
- With Push all branches and tags, the checks run one branch at a time. Giving up on one of them cancels the whole publication: nothing is created on the server.
- With Only add the remote, without pushing, there's no push check.
- If the project was already created and only the push failed, Try again goes through the checks again before the push.
- It checks the push (the checks above).
- It creates the project through the server's API (GitLab or GitHub), with the name, path, description and visibility.
- It adds the remote and pushes:
git remote add origin https://gitlab.exemplo.com/equipe/app.git
# Push main and set the upstream
git push -u origin refs/heads/main:refs/heads/main
# Push all branches and tags
git push -u origin --all
git push origin --tags
The project may be created and the push fail (network, git credential, hook). In that case:
- the dialog stays open, with "The project equipe/app was created, but the remote or the push failed. The reason is in the notification.";
- the summary then says "The project equipe/app has already been created. Check the remote and try the push again.";
- the button becomes Try again, which only redoes the remote and the push (the project isn't created again).
The project stays on the server. The dialog warns: "The project stays on GitLab: undo (Ctrl+Z) only reverts what changed in this repository. To delete the project, use its page." To remove the added remote, use Remove origin… in the remote's menu (see Remotes).
- "There's no GitLab or GitHub with a token in Git servers. Add a server to publish.": use Open Git servers and register the server.
- "A project with that name already exists in equipe (gitlab.exemplo.com). Choose another name."
- "Your account can't create projects in equipe."
- "The path only accepts letters, digits, "_", "-" and ".", and can't start with "-" or ".".": fix the Path (GitLab).
- "On GitHub the name only accepts letters, digits, "-", "_" and "." (up to 100).": fix the name.
- "Not allowed here: the project can't be more open than its group.": the chosen visibility is more open than the group's.
- "Internal visibility only exists in GitHub Enterprise organizations."
- "This repository already has a remote named origin.": change the Remote name.
- "Invalid remote name: use letters, digits, "_", "-" and "."."
- "No current branch (detached HEAD): choose to push all branches."
- "GitLab at gitlab.exemplo.com didn't answer the accounts and groups API (wrong address or the server lacks this feature).": check the registered server.
- The server must be in Git servers with a token or an OAuth login (the
apiscope on GitLab,repoon GitHub). - The
allowed_serverspolicy restricts the servers accepted (see Administrators).