# git

> For the complete documentation index, see [llms.txt](https://docs-stg.ringleader.dev/llms.txt).


> Your git identity on every workstation, so you never run git config --global inside one.


Install git with the [`git` devtool](https://docs-stg.ringleader.dev/reference/tools/devtools/git/) (or
`packages: [git]`), and this toolconfig writes your `~/.gitconfig` so commits are
attributed to you from the first one:

```yaml
devtools:
  - name: git
toolconfigs:
  - id: git
    name: git
    config:
      userName: Ada Lovelace
      userEmail: ada@example.com
```

That is all most people need. To set any other global git setting, see
[`settings`](#any-other-setting).

## Any other setting

`settings` takes any global git setting as a dotted key. A key is `section.key`, or
`section.subsection.key` when git's syntax needs a subsection. Values may be strings,
numbers or booleans.

```yaml
config:
  userName: Ada Lovelace
  userEmail: ada@example.com
  settings:
    init.defaultBranch: main
    pull.rebase: true
    core.editor: vim
    diff.colorMoved: zebra
```

renders as:

```ini
[core]
	editor = "vim"
[diff]
	colorMoved = "zebra"
[init]
	defaultBranch = "main"
[pull]
	rebase = true
```

Keys are sorted so the output is stable; strings are quoted, booleans and numbers are
not. A key with no section, or a `null` value, is refused with a clear error.

## `config` fields

| Field | Type | Description |
|-------|------|-------------|
| `userName` | `string` | `user.name`. |
| `userEmail` | `string` | `user.email`. |
| `settings` | `object` | Any other global git setting, as dotted key to value. |

## Example

A personal layer that lands your identity on every workstation you own, including ones
you create later, because it selects by label rather than by name:

```yaml
apiVersion: workstations.ringleader.dev/v1
kind: WorkstationConfig
metadata:
  name: my-git-identity
  namespace: local
spec:
  selector:
    matchLabels:
      owner: ada
  priority: 200
  devtools:
    - name: git
  toolconfigs:
    - id: git
      name: git
      config:
        userName: Ada Lovelace
        userEmail: ada@example.com
        settings:
          init.defaultBranch: main
          pull.rebase: true
```

## Notes

- The file belongs to the login user, is readable by nobody else, and is rewritten
  every time the workstation applies its configuration, so edits inside the workstation
  revert.
- Values may carry `${secret:NAME}` references, resolved inside the workstation. Do not
  put a credential in a git URL.
- To clone and push private repositories, use HTTPS git with
  credential injection, as [Injected credentials](https://docs-stg.ringleader.dev/security/credentials/injected-credentials/)
  shows. It adds the credential outside the workstation. A `sources[].git.credentialRef` hands its token or deploy
  key to the workstation for the clone it makes. An
  [SSHKey](https://docs-stg.ringleader.dev/reference/resources/sshkey/) lets every program in the workstation sign with
  your key while it is forwarded.

