Skip to main content

Git

The Git plugin brings repositories into workspaces. People connect their accounts on GitHub, GitLab or Gitea (Forgejo too, as a gitea host), or keep a token for any Git host; a workspace clones the repositories its template names and those its creator picks; and git in the workspace fetches and pushes with the creator's credentials. Turn it on on the Plugins page.

Providers​

People connect an account in a click through a provider: an OAuth application registered on a Git host. Register one on each host, with <external URL>/v1/git/callback as its callback URL, and add it on the Git page of the administration, which shows that URL ready to copy and says where each kind of host registers applications. The page edits the git settings section, which a settings file may set as well:

settings:
git:
allow_insecure_http: false # Leave false outside isolated development environments
providers:
- {name: github, kind: github, title: GitHub, base_url: https://github.com, client_id: ..., client_secret: ...}
- {name: lab, kind: gitlab, title: GitLab, base_url: https://gitlab.example.org, client_id: ..., client_secret: ...}
KindRegistered atRead-write scopesRead-only scopes
githubSettings → Developer settings → OAuth Apps. GitHub Enterprise works with its own base_url.repo, read:user, user:emailNot offered by GitHub classic OAuth
gitlabUser or group settings → Applications, or the admin area for the whole instance.read_user, read_api, read_repository, write_repositoryread_user, read_api, read_repository
gitea (Gitea and Forgejo)User settings → Applications → OAuth2 applications, as a confidential client.write:repository, read:userread:repository, read:user

Provider addresses, personal access token hosts, and repository URLs must use https:// by default and may never embed credentials (user:password@, rejected as git_url_userinfo). Plain http:// URLs are rejected (git_insecure_url) unless an administrator explicitly enables git.allow_insecure_http.

The platform's external URL must be set, since providers send people back to it. Tokens of providers that make them expire, GitLab and Gitea among them, are renewed before they run out by the job git.refresh (and refreshed on demand if already expired when a workspace or repository listing asks for them); a refresh token is spent once, so only one replica renews a given account.

Accounts​

On their profile, under Git, people see each provider and whether they are connected through it, connect (choosing read-write or read-only scopes on GitLab and Gitea/Forgejo) or disconnect in a click, and add a token for any other host with its address and their username there. An account is kept per host: connecting the same host again replaces it. Tokens are sealed in the database and never shown again. Connecting and removing accounts is audited as git.connect and git.disconnect.

Disconnecting a GitHub or GitLab OAuth account revokes the token upstream before removing it locally (DELETE /applications/{client_id}/grant on GitHub; POST /oauth/revoke for refresh and access tokens on GitLab). If upstream revocation fails, the disconnect fails closed (502 git_revoke_failed) unless the user explicitly confirms a forced local unlink (?force=true). Gitea/Forgejo OAuth apps and personal access tokens are removed locally with a notice reminding the user to revoke the grant or token on the Git host.

Only workspaces of someone's personal team use their accounts. Members of a team may open the team's workspaces, so those get nobody's credentials and clone public repositories only.

Repositories in workspaces​

A template names the repositories every workspace clones:

git:
- url: https://github.com/example/course.git
ref: v2 # a branch or tag; the default branch when left out
dir: course # relative to $HOME, or an absolute path under a mounted volume (e.g. /data/course)
mode: ro # rw (default), ro (push disabled locally), or clone_only (no runtime credentials)
shallow: true # optional: --depth 1

Each repository supports three credential modes and an optional shallow clone flag:

  • rw (default): Repo-scoped credentials are available for fetches and pushes against that attached repository.
  • ro: Configures remote.origin.pushurl to no_push after cloning so accidental pushes fail immediately; pair with a read-only GitLab or Gitea account when available. Note that GitHub classic OAuth does not offer a private read-only scope—use clone_only when strict no-write isolation is required on GitHub.
  • clone_only: Uses the credential once during initial provisioning, then immediately purges it from sidecar memory so runtime git commands inside the workspace receive no credentials for that repository.
  • shallow: Clones with --depth 1 (and --single-branch when ref is set).

When creating a workspace—or later from its details panel or edit page—people can add up to eight repositories in all (including the template's), picked from those their accounts reach or given by URL, and choose or edit each repository's target mount point, directory ($HOME or any writable volume mounted on the workspace; system directories such as /etc, /run, /var, /usr, /bin, /proc, and /sys are rejected), mode, and shallow setting. Each repository is cloned before the template's tasks run, one after the other, the first one to take a directory winning. Adding a repository or changing its target directory on a running workspace clones it live without restarting the workspace or re-running template tasks; removing a repository stops syncing it and leaves all existing files on disk untouched. A clone happens once: it is done when its directory exists, and one that fails leaves nothing behind and is tried again on the next revision or start. The workspace's details and edit page show whether each repository is cloned, and its tasks list each clone, named git-<directory>, with its output. Updating a workspace's repositories is audited as git.repositories_update.

In a personal workspace with attached repositories, credentials are kept solely in sidecar memory—never written to disk or .git/config—and served over a Unix domain socket (/run/idekube/git.sock, verified with SO_PEERCRED to reject nobody). Git is configured with credential.useHttpPath=true, so each credential is scoped strictly to the exact attached (scheme, host, repository path); workspaces with zero repositories receive zero credentials, and unattached repositories on the same host receive none. The workspace also receives a default commit identity (user.name and user.email) from the connected Git account or IDEKube profile whenever the user has not set their own in ~/.gitconfig or .git/config. Both credentials and identity follow account changes and token renewals without a restart.

Turning it off​

Workspaces lose the credentials at once and clone nothing more; what they cloned stays. Accounts and repositories are kept for when the plugin is turned on again.