|
| 1 | +# Configuration |
| 2 | + |
| 3 | +## Config file location |
| 4 | + |
| 5 | +Profiles are stored at: |
| 6 | + |
| 7 | +```text |
| 8 | +$XDG_CONFIG_HOME/git-profile/config.json |
| 9 | +``` |
| 10 | + |
| 11 | +Which defaults to `~/.config/git-profile/config.json` if `XDG_CONFIG_HOME` is not set. |
| 12 | + |
| 13 | +## Custom config path |
| 14 | + |
| 15 | +Use `--config` to point at a different file: |
| 16 | + |
| 17 | +```bash |
| 18 | +git-profile --config ~/dotfiles/git-profile.json list |
| 19 | +``` |
| 20 | + |
| 21 | +## Config file format |
| 22 | + |
| 23 | +```json |
| 24 | +{ |
| 25 | + "version": 1, |
| 26 | + "profiles": { |
| 27 | + "work": { |
| 28 | + "id": "work", |
| 29 | + "git_user": "Jane Dev", |
| 30 | + "git_email": "jane@company.com", |
| 31 | + "ssh_key_path": "~/.ssh/id_ed25519_work", |
| 32 | + "gpg_key_id": "ABC123DEF456", |
| 33 | + "sign_commits": true |
| 34 | + }, |
| 35 | + "personal": { |
| 36 | + "id": "personal", |
| 37 | + "git_user": "Jane Doe", |
| 38 | + "git_email": "jane@example.com", |
| 39 | + "ssh_key_path": "~/.ssh/id_ed25519_personal" |
| 40 | + }, |
| 41 | + "oss": { |
| 42 | + "id": "oss", |
| 43 | + "git_user": "Jane Doe", |
| 44 | + "git_email": "jane@oss.dev" |
| 45 | + } |
| 46 | + } |
| 47 | +} |
| 48 | +``` |
| 49 | + |
| 50 | +## Profile fields |
| 51 | + |
| 52 | +| Field | Type | Description | |
| 53 | +| -------------- | ------ | ----------------------------------------- | |
| 54 | +| `id` | string | Unique profile identifier | |
| 55 | +| `git_user` | string | `user.name` written to git config | |
| 56 | +| `git_email` | string | `user.email` written to git config | |
| 57 | +| `ssh_key_path` | string | Path to SSH private key (`~/` supported) | |
| 58 | +| `gpg_key_id` | string | GPG key ID written to `user.signingkey` | |
| 59 | +| `sign_commits` | bool | Sets `commit.gpgsign = true` when applied | |
| 60 | + |
| 61 | +## How git config keys are mapped |
| 62 | + |
| 63 | +When you run `git-profile use <id>`, only fields present in the profile are written: |
| 64 | + |
| 65 | +| Profile field | git config key | |
| 66 | +| -------------- | ----------------- | |
| 67 | +| `git_user` | `user.name` | |
| 68 | +| `git_email` | `user.email` | |
| 69 | +| `ssh_key_path` | `core.sshCommand` | |
| 70 | +| `gpg_key_id` | `user.signingkey` | |
| 71 | +| `sign_commits` | `commit.gpgsign` | |
| 72 | + |
| 73 | +Fields absent from the profile are left unchanged in git config. |
| 74 | + |
| 75 | +## Environment variables |
| 76 | + |
| 77 | +| Variable | Description | |
| 78 | +| ----------------- | ----------------------------------------------------- | |
| 79 | +| `XDG_CONFIG_HOME` | Base directory for config file (default: `~/.config`) | |
| 80 | + |
| 81 | +## Dotfiles integration |
| 82 | + |
| 83 | +Because the config file is plain JSON, you can symlink or copy it from your dotfiles: |
| 84 | + |
| 85 | +```bash |
| 86 | +# symlink from dotfiles |
| 87 | +ln -s ~/dotfiles/git-profile.json ~/.config/git-profile/config.json |
| 88 | + |
| 89 | +# or use --config flag in a shell alias |
| 90 | +alias gp='git-profile --config ~/dotfiles/git-profile.json' |
| 91 | +``` |
0 commit comments