repown 0.1.1 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -7,6 +7,80 @@ commands. How a release is cut: [docs/RELEASING.md](docs/RELEASING.md).
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.3.0] - 2026-09-29
11
+
12
+ ### Changed
13
+
14
+ - In a terminal, bare `repown` outside a clone, or in a bare repository, opens a
15
+ start screen. It shows the accounts on this machine, whether gh serves git's
16
+ credentials, and the clones found up to 2 levels below, then offers the next
17
+ command. Nothing changes until you pick one. Quit exits 0; Esc or Ctrl-C exits
18
+ 130. With stdout redirected, a clone still prints status, and outside a clone it
19
+ still prints help (exit 0). Without a terminal on stdin or stderr, it is still
20
+ status.
21
+ - The start screen draws its summary inside its frame, and closes that frame with
22
+ the command it is about to run. Show help closes with `> repown --help`, then
23
+ prints the help. Inside a clone, bare `repown` draws its opening sentence inside
24
+ setup's frame. Typing `<` at Record an account's login question returns to the menu.
25
+ - The start screen looks inside a directory whose `.git` git refuses, with the levels
26
+ it has left, and does not search a bare repository for clones. Account names, and
27
+ the folder in the title, show control characters as escapes.
28
+
29
+ ## [0.2.0] - 2026-09-28
30
+
31
+ ### Added
32
+
33
+ - `repown setup`: a guided setup of the clone you're in. It asks which account owns
34
+ it (and records a new one), whether this clone may push to origin's owner, whether
35
+ to turn the guard on, whether to push branches without `-u` (git 2.37+), whether to
36
+ switch gh or sign the account in to gh, and whether to stop gh being git's
37
+ credential helper (`fix`, machine-wide). The review lists only steps that would
38
+ change something, nothing changes until you choose Run, and the run ends by listing
39
+ what changed in the clone and on the machine.
40
+ - **Recommended** (the default) asks only what it must and fills in the rest; the
41
+ steps still show in the review, where you can change any answer. **Step by step**
42
+ (`--step-by-step`) asks every question, then confirms each step (Yes, Skip or
43
+ Stop) before running it.
44
+ - The first question lists the accounts it can already see (origin's owner, gh's,
45
+ Git Credential Manager's) and suggests the one that owns the repository.
46
+ - Every question is also a flag, and `--no-input` runs it from a script. Exit
47
+ codes: 0 done or already set up, 1 declined or can't start, 2 for flags that
48
+ don't fit, 130 on Esc or Ctrl-C, and a failed step's own code.
49
+ - A clone that is already set up opens on **This clone is already set up**, with
50
+ Done, Use another account, and a gh option when gh acts as someone else.
51
+ - In a plain terminal it asks with numbered choices.
52
+ - `repown use <account> --gh` signs the account in to gh when gh doesn't list it
53
+ (in a terminal, gh 2.40 or later).
54
+ - `repown use` warns about commits on the branch that no remote has yet and that
55
+ another address authored, which the guard would refuse, and prints the rebase that
56
+ re-authors them. Setup's review notes the same.
57
+ - `repown guard on` warns when it runs from npx's cache, because the hook would call a
58
+ temporary copy that later disappears.
59
+ - One optional runtime dependency, `@clack/prompts` 1.8.1, pinned and locked by the
60
+ `npm-shrinkwrap.json` that now ships. Only `repown setup` loads it, never the
61
+ pre-push hook; where it can't load, setup falls back to plain prompts.
62
+
63
+ ### Changed
64
+
65
+ - In a terminal, bare `repown` in a clone always opens `repown setup`, set up or not.
66
+ Outside a clone it shows help; without a terminal, or with output redirected, it
67
+ still prints status, so scripts and CI get the report.
68
+ - `repown status` says what it shows: a title, the clone's path and branch, "This
69
+ clone" and "This machine" groups, the branch's upstream, whether the account is
70
+ recorded, and a closing count. The verdict comes first. gh acting as another
71
+ account is an optional note, not a warning, and it names a gh fix that works.
72
+ - `repown doctor` shows each account's readiness for git and for gh, and ends with
73
+ one verdict line. The SSO reminder is one sentence naming the host.
74
+ - On Windows, `status` and `doctor` show paths with backslashes.
75
+ - Docs: the README starts with `repown setup` and keeps what a new user needs.
76
+ Configuration moved to docs/CONFIGURATION.md, and the FAQ and the comparison with
77
+ other approaches to docs/FAQ.md. SECURITY.md explains private reporting.
78
+
79
+ ### Fixed
80
+
81
+ - `repown help scan` said `--emails` dropped the counts; it keeps them and shows
82
+ exact addresses instead of domains.
83
+
10
84
  ## [0.1.1] - 2026-09-25
11
85
 
12
86
  - Fixed: `repown use -` (and `accounts add -`, `accounts remove -`, `scan -`) is a
@@ -31,6 +105,8 @@ commands. How a release is cut: [docs/RELEASING.md](docs/RELEASING.md).
31
105
  contract for scripts.
32
106
  - Runs on Node 20+ on Windows, macOS and Linux, with zero runtime dependencies.
33
107
 
34
- [Unreleased]: https://github.com/makubexD/repown/compare/v0.1.1...HEAD
108
+ [Unreleased]: https://github.com/makubexD/repown/compare/v0.3.0...HEAD
109
+ [0.3.0]: https://github.com/makubexD/repown/compare/v0.2.0...v0.3.0
110
+ [0.2.0]: https://github.com/makubexD/repown/compare/v0.1.1...v0.2.0
35
111
  [0.1.1]: https://github.com/makubexD/repown/compare/v0.1.0...v0.1.1
36
112
  [0.1.0]: https://github.com/makubexD/repown/releases/tag/v0.1.0
package/README.md CHANGED
@@ -6,211 +6,376 @@
6
6
  [![Node](https://img.shields.io/node/v/repown.svg)](package.json)
7
7
  [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
8
8
 
9
- **Use several git accounts on one machine, and move between their repositories
10
- with no switch command.** Each repo owns its identity (that's the name: *repo
11
- own*), so you can go from a work repo to a personal one to a client one, on
12
- different hosts or sign-in methods, and every commit and push goes out as the
13
- right account. A push carrying the wrong identity is refused before it leaves.
9
+ **Stop committing and pushing as the wrong account when one machine has two or more.**
10
+ Each repository owns its identity (that's the name: *repo own*), so you move from a work
11
+ repo to a personal one to a client one, on any host or sign-in method, with no switch
12
+ command. A push carrying commits under the wrong identity is refused before it leaves.
13
+
14
+ **Day to day:**
14
15
 
15
16
  ```
16
- repown doctor # once per machine: is git's credential helper ready?
17
- repown use octocat # once per clone: this clone is octocat's
18
- repown guard on # refuse any push that carries another identity
17
+ ~/code/work $ git push # 🟢 signs in as octo-work
18
+ ~/code/personal $ git push # 🟢 signs in as octocat, no switch command
19
+ ~/code/personal $ git push # 🔴 refused: a commit authored as octo-work
20
+ ~/code/client $ repown status # 🟡 guard off: pushes are not checked
19
21
  ```
20
22
 
21
23
  > **Status:** pre-1.0: the commands may still change. What changed in each version is in
22
24
  > [CHANGELOG.md](CHANGELOG.md).
23
25
 
24
- ## The problem
26
+ **Contents:** 🤔 [Why repown](#why-repown) · 📦 [Install](#install) ·
27
+ ⚡ [Quick start](#quick-start) · ⌨️ [Commands](#commands) ·
28
+ 🩺 [Troubleshooting](#troubleshooting) · 🛠️ [Set up by hand](#set-up-by-hand) ·
29
+ 🧹 [Uninstall](#uninstall) · 📚 [More docs](#more-docs)
25
30
 
26
- - **Every clone inherits the identity in your global git config.** A commit's author
27
- address becomes permanent once it's pushed to a public repository.
28
- - **`gh auth switch` changes the account for the whole machine.** While `gh` is git's
29
- credential helper, every switch breaks the *other* account's repositories. An
30
- SSO-only account has no password to type at the prompt
31
- ([ADR-001](docs/decisions/ADR-001-credential-manager-not-gh.md)).
31
+ ## Why repown
32
32
 
33
- ## How repown solves it
33
+ **The problem:**
34
34
 
35
- - **Pin each clone:** `repown use <account>` writes the commit identity and the push
36
- account into that clone's `.git/config`. It is set once and never switched.
37
- - **One credential per account:** Git Credential Manager already stores one
38
- credential per account and picks it per clone.
39
- - `repown doctor` checks that it is the helper.
40
- - `repown fix` hands the host back to it if `gh auth setup-git` took over.
41
- - `gh` stays your account store for `gh pr create` and `gh api`.
35
+ - ❌ **Every clone inherits the identity in your global git config.** A commit's author
36
+ address becomes permanent once it's pushed to a public repository.
37
+ - ❌ **`gh auth switch` changes the account for the whole machine.** While `gh` (the GitHub
38
+ CLI) is git's *credential helper* (the program git asks for a password or token), every
39
+ switch breaks the *other* account's repositories. And if your organisation signs you in
40
+ through single sign-on (SSO), there's no password you could type at that prompt anyway
41
+ ([ADR-001](docs/decisions/ADR-001-credential-manager-not-gh.md)).
42
42
 
43
- Credential pinning is GitHub-over-https only today. Commit identity and the guard
44
- work on every host ([ADR-009](docs/decisions/ADR-009-hosts-claim-only-measured.md)).
45
- - **Guard every push:** `repown guard on` installs a `pre-push` hook that checks the
46
- commits themselves, not just today's config.
43
+ **What repown does:**
47
44
 
48
- **Every scenario, with diagrams: [docs/HOW-IT-WORKS.md](docs/HOW-IT-WORKS.md).**
45
+ - ✅ **Pins each clone.** It writes the commit identity and the push account into that
46
+ clone's own `.git/config`. That's what *pinned* means here: set once, never switched.
47
+ - ✅ **Lets one credential serve each account.**
48
+ [Git Credential Manager](https://github.com/git-ecosystem/git-credential-manager) (GCM)
49
+ stores one sign-in per account and picks the one each clone names. `repown doctor`
50
+ checks GCM is the helper; if gh has become it (`gh auth login` offers that),
51
+ `repown fix` removes gh's entries after showing them. `gh` stays your account store for
52
+ `gh pr create` and `gh api`.
53
+ - ✅ **Guards every push.** A git `pre-push` hook (a script git runs before every push),
54
+ the *guard*, checks the commits being pushed, not just today's config.
49
55
 
50
- ## Compared with the alternatives
56
+ **Where it works:**
51
57
 
52
- | Approach | Right commit identity | Right push credential | Checked before push | Catch |
53
- | --- | --- | --- | --- | --- |
54
- | `git config user.email` by hand in each repo | yes, if you never forget | no | no | Forgetting once publishes the wrong address permanently |
55
- | `includeIf "gitdir:~/work/"` in global config | yes, by folder | only if you also add the credential key per folder | no | Depends on where a repo happens to be cloned; a clone anywhere else inherits the default |
56
- | SSH host aliases (`git@github-work:...`) | no | yes | no | Every remote URL has to be rewritten, and keys managed per account |
57
- | `gh auth switch` | no | while gh is the helper, only the *active* account | no | Machine-wide: it breaks the other account's repos |
58
- | **repown** | yes, per clone | yes, per clone (GitHub) | yes, once `repown guard on`: every commit the push would publish | `use` and `guard on` once per clone |
58
+ | | Commit identity | Guard | Push sign-in pinned |
59
+ | --- | --- | --- | --- |
60
+ | GitHub over https | ✅ | ✅ | ✅ (github.com) |
61
+ | GitHub over SSH | ✅ | ✅ | ➖ your key decides which account pushes |
62
+ | Azure DevOps and other hosts | ✅ | ✅ | ❌ not pinned ([ADR-009](docs/decisions/ADR-009-hosts-claim-only-measured.md)) |
59
63
 
60
- repown doesn't replace these tools. It writes plain repo-local git config, uses the
61
- credential manager you already have, and leaves `gh` in charge of the GitHub CLI.
64
+ Every scenario, with diagrams: [docs/HOW-IT-WORKS.md](docs/HOW-IT-WORKS.md).
62
65
 
63
66
  ## Install
64
67
 
65
- Needs Node 20+ and git, on Windows, macOS or Linux.
68
+ **You need:**
69
+
70
+ - **Node 20+** and **git**, on Windows, macOS or Linux.
71
+ - **Git Credential Manager** for per-account sign-in on GitHub. Git for Windows includes
72
+ it; on macOS and Linux, follow
73
+ [GCM's install guide](https://github.com/git-ecosystem/git-credential-manager/blob/main/docs/install.md).
74
+ - **gh** is optional: repown reads it when it's there.
66
75
 
67
76
  ```
68
77
  npm install -g repown
69
78
  ```
70
79
 
71
- To try it without installing, run `npx repown doctor`. The package has no runtime
72
- dependencies. From 0.1.1 on, each version is published from CI with
73
- [provenance](https://docs.npmjs.com/generating-provenance-statements), so npm shows the
74
- commit and workflow that built it (0.1.0 was published by hand, and has none). Update with `npm install -g repown@latest`; a guarded
75
- clone keeps working, because its hook calls the installed CLI
76
- ([ADR-003](docs/decisions/ADR-003-hook-calls-installed-cli.md)).
77
-
78
- To uninstall, run `repown guard off` in each guarded clone **first**: a guard that can't
79
- find repown refuses every push
80
- ([the steps](docs/HOW-IT-WORKS.md#12-uninstall-or-repown-missing)).
80
+ - **Install it globally:** the guard calls the installed repown. To try it first,
81
+ `npx repown` runs commands that only read (`repown status`, `repown doctor`,
82
+ `repown scan`), but don't turn the guard on through `npx`: its hook would call a
83
+ temporary copy ([card 12](docs/HOW-IT-WORKS.md#12-uninstall-or-repown-missing)).
84
+ - **Update** with `npm install -g repown@latest`; guarded clones keep working
85
+ ([ADR-003](docs/decisions/ADR-003-hook-calls-installed-cli.md)).
86
+ - **What gets installed:** one optional dependency, for the arrow-key prompts (without it,
87
+ `repown setup` and the start screen ask with numbered choices), pinned exactly
88
+ ([ADR-016](docs/decisions/ADR-016-clack-for-the-setup-wizard.md)). The package is
89
+ published from CI with provenance ([how](SECURITY.md#how-the-package-is-published)).
81
90
 
82
- ## Quickstart
91
+ ## Quick start
83
92
 
84
- **Once per machine:** `repown doctor`, then `repown fix` only if doctor says so. `fix`
85
- shows what it removes, and the undo, before changing anything.
93
+ ```
94
+ repown doctor # once per machine: is Git Credential Manager ready for sign-ins?
95
+ cd ~/code/my-repo
96
+ repown # in a terminal: starts the guided setup of this clone
97
+ ```
86
98
 
87
- **Once per clone:**
99
+ 1. **`repown doctor`, once per machine.** It ends with a verdict:
100
+ - 🟢 `ready: each clone signs in as its own account through Git Credential Manager`
101
+ - 🔴 `1 problem: gh answers git's sign-in requests: run repown fix`
102
+
103
+ If gh is the helper, or something is missing, see [Troubleshooting](#troubleshooting).
104
+ 2. **Clone as usual,** then from inside a new clone just type **`repown`.** That starts
105
+ the guided setup. **`repown setup`** still works. (Cloning a private repository signs
106
+ in first: pick the account that owns it.) It asks how setup should work. Recommended is
107
+ the default. Answers it fills in still appear in the review.
108
+
109
+ | Question | Recommended | Step by step | Flag |
110
+ | --- | --- | --- | --- |
111
+ | Which account should this clone belong to? | Asked. `repown setup <account>` skips the mode question and uses Recommended, so a recorded account goes straight to the review when nothing else must be asked. A new account also asks where it's hosted, the name and the email. | Asked | `<account>`, `--host`, `--name`, `--email` |
112
+ | Let this clone push to origin's owner? Asked when origin belongs to someone else, like an organisation. | Asked, default Yes. No means the guard refuses pushes there. | Asked, default Yes | `--allow-owner <owner>` |
113
+ | Turn the guard on? | Answers Yes without asking | Asked | `--guard` |
114
+ | Push branches without -u? Only on git 2.37+. It sets `push.autoSetupRemote` in this clone only; the guard still checks that first push. | Answers Yes without asking | Asked, default Yes | `--auto-upstream` |
115
+ | gh. "Switch gh too" makes `gh pr create` match. | Switches without asking when gh already lists the account and the clone is not already pinned to it. A sign-in, which opens a browser, is asked, default No. Skips the question when the clone is already pinned to that account. | Asked | `--gh` |
116
+ | Take git's sign-ins back from gh? Machine-wide. | Asked, default No. Answer Yes if `repown doctor` said gh is the helper, or pushes from your other account's clones fail. | Asked, default No | `--fix` |
117
+
118
+ Step by step asks every question: `--step-by-step`.
119
+ `--no-input` asks nothing ([scripts and CI](docs/CONFIGURATION.md#scripts-and-ci)).
120
+
121
+ - **In your first clone,** it lists the accounts it can already see on GitHub (origin's
122
+ owner, gh's accounts, Git Credential Manager's) and suggests origin's owner when that
123
+ owner is a user, or asks for the login. On GitHub, use your *noreply* address, shown
124
+ at github.com/settings/emails (like `1234+octocat@users.noreply.github.com`).
125
+ - **In later clones,** it lists the accounts it knows: pick one, or **a new account**.
126
+ 3. **Check the review, then choose Run them.** Nothing changes before that:
127
+
128
+ ```
129
+ ◇ Review: nothing has changed yet ───────────────────────────────────────╮
130
+ │ │
131
+ │ This clone will commit and push as octocat. │
132
+ │ │
133
+ │ When you choose Run: │
134
+ │ 1. Let this clone push to octo-org's repositories │
135
+ │ git config --local --add repown.allowOwner octo-org │
136
+ │ 2. Pin this clone to octocat: its commit name, email and push sign-in │
137
+ │ repown use octocat │
138
+ │ 3. Turn on the push guard: each push is checked first │
139
+ │ repown guard on │
140
+ │ 4. Push branches without -u: the first push sets the upstream (this │
141
+ │ clone only) │
142
+ │ git config --local push.autoSetupRemote true │
143
+ │ │
144
+ │ These are ordinary commands: run them yourself, or in a script. │
145
+ │ This clone's settings go in its .git/config, which is never pushed. │
146
+ │ │
147
+ ├─────────────────────────────────────────────────────────────────────────╯
148
+ │
149
+ ◆ Run these 4 steps?
150
+ │ ● Run them
151
+ │ ○ Back
152
+ │ ○ Change an answer
153
+ │ ○ Decline
154
+ │ ↑/↓ to navigate • Enter: confirm
155
+ └
156
+ ```
157
+
158
+ 4. **Push.** The first push from each account signs in once: GCM opens a browser, and you
159
+ sign in as *that* clone's account, not whichever you used last. After that, pushes from
160
+ that clone use it without asking. When setup set `push.autoSetupRemote`, the first
161
+ `git push` of a branch without an upstream also creates it on origin. When it did not
162
+ (older git, a version repown could not read, or you answered No), use
163
+ `git push -u origin <branch>` once.
164
+
165
+ **Keys:** ↑/↓ choose, Enter confirms, Esc or Ctrl-C stops with nothing changed. From the
166
+ second question on, each list ends with **← Back**; at a typed answer, enter `<`. In a
167
+ plain terminal the questions come as numbered choices
168
+ ([when](docs/CONFIGURATION.md#environment-variables)); there, Ctrl-C stops.
169
+
170
+ **Running it again.** Run `repown` in a clone that's already set up, or `repown setup`
171
+ with no account and no flags, and setup opens on this screen, before any question:
88
172
 
89
173
  ```
90
- $ repown use octocat
91
- OK identity Octo Cat <octocat@users.noreply.github.com> push-as:octocat
174
+ ◇ This clone is already set up ─────────────────────────────────────╮
175
+ │ │
176
+ │ commits as Octo Cat <octocat@users.noreply.github.com> │
177
+ │ pushes as octocat │
178
+ │ guard on: every push is checked before it leaves │
179
+ │ upstream origin/main │
180
+ │ │
181
+ │ Nothing needs to change. │
182
+ │ │
183
+ │ Checked: the settings git uses here are octocat's, as recorded. │
184
+ │ See it any time: repown status (this clone), repown doctor (this │
185
+ │ machine) │
186
+ │ │
187
+ ├────────────────────────────────────────────────────────────────────╯
188
+ │
189
+ ◆ What now?
190
+ │ ● Done (change nothing)
191
+ │ ○ Use another account
192
+ │ ↑/↓ to navigate • Enter: confirm
193
+ └
194
+ ```
92
195
 
93
- No stored credential for "octocat" yet -- the first push signs in
94
- once, then never again. Verify it afterwards: repown doctor
196
+ **Done** changes nothing. **Use another account** asks which account this clone should
197
+ use. When gh acts as someone else, a third option is **Sign in to gh as `<account>`** (or
198
+ **Make `<account>` gh's active account** when gh already lists it) and runs
199
+ `repown use <account> --gh`. The upstream line shows the tracked branch (for example
200
+ `origin/main`) when there is one, otherwise `set on the first push (push.autoSetupRemote)`
201
+ when that setting is on, otherwise nothing. It is the same value `repown status` shows,
202
+ and `repown status` shows all of this without asking. Every screen:
203
+ [card 13](docs/HOW-IT-WORKS.md#13-guided-setup).
95
204
 
96
- Next: repown guard on (check every push before it leaves)
205
+ ## Commands
97
206
 
98
- $ repown guard on
99
- OK guard on -- every push is checked before it leaves
100
- /path/to/clone/.git/hooks/pre-push
101
- ```
207
+ After setup, **moving between accounts needs no command**: `cd` into any pinned clone,
208
+ then commit and push.
102
209
 
103
- The first time, `repown use` asks for the account's commit name and email and records
104
- them for every other clone. Without a terminal it can't ask, so record the account
105
- first: `repown accounts add octocat --name "Octo Cat" --email octocat@users.noreply.github.com`.
210
+ | When | Command | What it does |
211
+ | --- | --- | --- |
212
+ | Once per machine | `repown doctor` | what serves credentials on this machine, and whether each account is signed in to git and gh |
213
+ | | `repown fix [--dry-run] [--yes]` | undo `gh auth setup-git`, so each clone's pinned account is used; shows what it removes, and the undo, first |
214
+ | Once per clone | `repown setup [<account>]` | guided setup of this clone. Questions, flags and the review: [Quick start](#quick-start). A clone that is already set up opens on that screen |
215
+ | | `repown use <account> [--gh]` | what setup runs: pin this clone to an account. `--gh` switches gh's active account, or signs the account in to gh when needed (in a terminal). `--name` with `--email` skips the registry, the file where repown remembers accounts |
216
+ | | `repown guard on \| off \| status` | install, remove or show the pre-push hook (bare `repown guard` shows it) |
217
+ | Any time | `repown status` | this clone's and this machine's settings, and what to fix. Exits 1 on a problem; warnings alone exit 0 |
218
+ | | `repown scan [dir...] [--emails] [--depth <n>] [--format json]` | every clone under the folders (default: this one, 3 levels deep): owner, host, identity, guard, and which email domains its history has. Changes nothing |
219
+ | Rarely | `repown accounts list \| add \| remove` | the accounts this machine knows (bare `repown accounts` lists them; `add` takes `--name`, `--email`, `--host github\|azdo\|generic`; `list --format json` for scripts) |
220
+ | | `repown off` | unpin this clone, leaving global config alone; warns if the guard is still on |
106
221
 
107
- It writes these repo-local keys and nothing else:
222
+ **Bare `repown`:**
108
223
 
109
- | Key | What it decides |
224
+ | Where | What it does |
110
225
  | --- | --- |
111
- | `user.name`, `user.email` | who **authored** the commit |
112
- | `repown.account` | whose clone this is; the guard checks the destination against it |
113
- | `credential.<host>.username` | which stored credential serves the **push** (GitHub over https only) |
114
- | `user.useConfigOnly` | git refuses to invent an identity from the hostname |
226
+ | A terminal, inside a clone (pinned or not) | Starts `repown setup`. A line inside that screen says the clone isn't set up yet, or that a pinned clone is being checked ([card 5](docs/HOW-IT-WORKS.md#5-check-where-you-are)) |
227
+ | A terminal, outside a clone or in a bare repository | Opens the start screen ([card 14](docs/HOW-IT-WORKS.md#14-outside-a-clone)) |
228
+ | stdout redirected (stdin and stderr still terminals) | Status inside a clone. The top help outside a clone, exit 0 |
229
+ | No terminal (stdin or stderr is not one) | Status. Exit 1 outside a clone |
115
230
 
116
- `.git/config` and `.git/hooks` are never pushed. No name or address reaches the
117
- repository, and teammates see nothing.
231
+ The start screen lists the accounts on this machine and the clones it found, then offers
232
+ the next command. The summary is in the frame. Picking a command closes the frame with
233
+ that command. Nothing changes until you pick one.
118
234
 
119
- ## Day to day
120
-
121
- **Moving between accounts needs no command.** `cd` into any pinned clone, then commit
122
- and push. To see who a clone is, run `repown`:
235
+ **Who is this clone?** `repown status` prints:
123
236
 
124
237
  ```
125
- $ repown
238
+ $ repown status
239
+
240
+ repown status · current settings of this clone
241
+ ~/code/personal (branch main)
126
242
 
243
+ This clone
127
244
  commits as Octo Cat <octocat@users.noreply.github.com>
128
245
  pushes as octocat
246
+ account octocat (recorded)
129
247
  origin octocat (GitHub)
248
+ upstream origin/main
249
+ push guard on
250
+
251
+ This machine
252
+ default Octo Work <octo-work@example.invalid>
130
253
  helper manager
131
254
  gh active octo-work
132
- push guard on
133
255
 
134
- WARN gh active as "octo-work", so `gh pr create` here would act as that account.
135
- fix: gh auth switch -u octocat
136
256
  OK identity this clone is pinned, and its credential mechanism honours it
257
+ NOTE gh active as "octo-work", so `gh pr create` here would act as that account. git pushes are unaffected; this only matters if you use gh here.
258
+ fix: gh auth switch -u octocat
259
+
260
+ ready: commits and pushes use octocat · gh: optional (see the note above)
137
261
  ```
138
262
 
139
- It prints all three things that decide who you are: the commit identity, the push
140
- credential, and gh's active account. The one you can't see is the one that catches
141
- you out.
263
+ Here git is right, and only `gh` commands would act as another account. That line is a
264
+ note, not a warning. Every warning it can print:
265
+ [card 5](docs/HOW-IT-WORKS.md#5-check-where-you-are).
266
+
267
+ - **Help:** `repown --help`, `repown help <command>` (or `repown <command> --help`), and
268
+ `repown help guard on` one level deeper. Help never changes anything.
269
+ - **Every command** takes `--cwd <dir>`. **Version:** `repown --version` (or `-v`).
270
+
271
+ **Exit codes:**
272
+
273
+ | Command | 0 | 1 | 2 | Other |
274
+ | --- | --- | --- | --- | --- |
275
+ | In general | Success | Failure or refusal | Usage error | |
276
+ | `repown scan` | Whatever it finds (read its output or JSON) | | A missing folder or a bad `--depth` | |
277
+ | `repown setup` | Done, or already set up | Decline, or it can't start | Flags that don't fit, or no terminal without `--no-input` | 130 when cancelled or interrupted; a failing step's own code |
278
+ | `repown status` | Success. Warnings alone exit 0 | A problem | | |
142
279
 
143
- **Audit every clone you have:** `repown scan ~/code ~/work` lists each clone's owner,
144
- host, identity and guard. It also shows which email domains appear in its history, and
145
- how often. It never changes anything.
280
+ Every `setup` case: [Scripts and CI](docs/CONFIGURATION.md#scripts-and-ci).
146
281
 
147
- **Something went wrong?**
282
+ ## Troubleshooting
148
283
 
149
- | What happened | Where to look |
284
+ | What happened | What to do |
150
285
  | --- | --- |
151
- | A push asked for a password | [card 1](docs/HOW-IT-WORKS.md#1-set-up-the-machine), then [card 6](docs/HOW-IT-WORKS.md#6-commit-and-first-push) |
152
- | A push failed after signing in (SSO) | [card 6](docs/HOW-IT-WORKS.md#6-commit-and-first-push) |
153
- | The guard refused a push | [card 8](docs/HOW-IT-WORKS.md#8-push-refused-and-the-fix) |
154
- | A teammate doesn't use repown | [card 9](docs/HOW-IT-WORKS.md#9-a-teammate-without-repown) |
155
- | husky or another hook tool | [card 10](docs/HOW-IT-WORKS.md#10-other-hook-tools) |
286
+ | `repown doctor` says gh is the helper | `repown fix` ([card 1](docs/HOW-IT-WORKS.md#1-set-up-the-machine)) |
287
+ | `repown doctor` shows `GCM` … `not found` | install Git Credential Manager ([Install](#install)), then `repown doctor` again |
288
+ | `repown doctor` shows `helper` … `none configured` | `git credential-manager configure`, then `repown doctor` again |
289
+ | A push asked for a password | `repown status` (this clone) or `repown doctor` (this machine): each names the cause (gh as the helper, or no helper) and the fix |
290
+ | A push failed right after signing in (SSO) | [card 6](docs/HOW-IT-WORKS.md#6-commit-and-first-push) |
291
+ | The guard refused a push | it says which commit and the fix. Most often a commit made before pinning: `git commit --amend --reset-author --no-edit` fixes the last one ([card 8](docs/HOW-IT-WORKS.md#8-push-refused-and-the-fix) for older ones, and every other refusal) |
292
+ | `gh pr create` acts as the wrong account | `gh auth switch -u <account>` when gh lists it, otherwise `repown use <account> --gh` |
293
+ | `git push` says the branch has no upstream | `repown setup --auto-upstream`, or once `git push -u origin <branch>` |
294
+ | The first push opened a browser | Expected, once per account. Git Credential Manager stores it |
295
+ | The guard said the push goes to another owner | if you're a member or collaborator there: `git config --local --add repown.allowOwner <owner>` |
296
+ | The guard said `GH_TOKEN` (or `GITHUB_TOKEN`, `GIT_AUTHOR_EMAIL`, `GIT_COMMITTER_EMAIL`) is set | unset it, then push again: the email variables override the pinned identity, and the token variables make gh serve that token |
297
+ | husky or another tool owns the pre-push hook | have that hook run `repown guard check --remote="$1" --url="$2"`, passing its stdin through; if the hook is committed, make it skip teammates without repown ([card 10](docs/HOW-IT-WORKS.md#10-other-hook-tools)) |
298
+ | An Azure DevOps push is refused as "wrong owner" | the owner there is the organisation: allow it with `git config --local --add repown.allowOwner <organisation>` |
299
+ | "repown cannot be found" on push | [card 12](docs/HOW-IT-WORKS.md#12-uninstall-or-repown-missing) |
300
+
301
+ A refused push:
156
302
 
157
- ## Commands
303
+ ```
304
+ FAIL guard 1 commit(s) bound for refs/heads/main were not authored as octocat@users.noreply.github.com, or were committed by someone else.
305
+ 6e7b31adb someone@example.invalid someone else's commit
306
+
307
+ These addresses become permanent once pushed.
308
+
309
+
310
+ Push stopped by the repown identity guard (above).
311
+ Override this one push with: git push --no-verify
312
+ ```
313
+
314
+ To push once without the check: `git push --no-verify`, only when you mean to publish
315
+ those addresses. What the guard can't catch (other git clients, submodule pushes):
316
+ [residual risks](docs/decisions/README.md#residual-risks).
317
+
318
+ ## Set up by hand
319
+
320
+ The same commands `repown setup` runs, if you'd rather type them:
321
+
322
+ 1. **Check the machine, once:** `repown doctor`.
323
+ 2. **Record each account, once:**
324
+ `repown accounts add octocat --name "Octo Cat" --email octocat@users.noreply.github.com`.
325
+ Optional: on a terminal, the first `repown use` of an unknown account asks. On GitHub
326
+ it suggests the name from the public profile and the noreply email (through gh)
327
+ ([card 2](docs/HOW-IT-WORKS.md#2-remember-an-account)).
328
+ 3. **In each clone:** `repown use octocat`, then `repown guard on`
329
+ ([card 3](docs/HOW-IT-WORKS.md#3-pin-a-clone)). If the repository belongs to another
330
+ owner, such as an organisation, `use` prints the line that allows it.
331
+
332
+ ```
333
+ $ cd ~/code/dotfiles
334
+ $ repown use octocat
335
+ OK identity Octo Cat <octocat@users.noreply.github.com> push-as:octocat
336
+
337
+ No stored credential for "octocat" yet -- the first push signs in
338
+ once, then never again. Verify it afterwards: repown doctor
339
+
340
+ Next: repown guard on (check every push before it leaves)
341
+
342
+ $ repown guard on
343
+ OK guard on -- every push is checked before it leaves
344
+ ~/code/dotfiles/.git/hooks/pre-push
345
+ ```
346
+
347
+ `.git/config` and `.git/hooks` are never pushed, so teammates see nothing of this setup.
348
+ Every key repown writes:
349
+ [docs/CONFIGURATION.md](docs/CONFIGURATION.md#what-repown-writes).
350
+
351
+ ## Uninstall
352
+
353
+ Turn the guard off **first**: a guard that can't find repown refuses every push.
354
+
355
+ ```
356
+ repown scan <dir> # the "guard" column shows where it's on
357
+ repown guard off # in each of those clones
358
+ repown off # optional: also drop the pinned identity
359
+ npm uninstall -g repown
360
+ ```
361
+
362
+ Left behind, on purpose: the account registry
363
+ ([where](docs/CONFIGURATION.md#the-account-registry)), which you can delete, and the
364
+ sign-ins in your OS credential store. If `repown fix` took the helper role from gh and you
365
+ want it back: `gh auth setup-git`. Details, and submodules:
366
+ [card 12](docs/HOW-IT-WORKS.md#12-uninstall-or-repown-missing).
367
+
368
+ ## More docs
158
369
 
159
- | Command | What it does |
370
+ | I want… | Read |
160
371
  | --- | --- |
161
- | `repown status` (or just `repown`) | the state of this repository and this machine |
162
- | `repown use <account> [--gh]` | pin this clone to an account (`--name` and `--email` together skip the registry) |
163
- | `repown off` | unpin this clone, leaving global config alone |
164
- | `repown doctor` | what serves credentials on this machine, and to whom |
165
- | `repown fix [--dry-run] [--yes]` | undo `gh auth setup-git` so per-clone pins work again |
166
- | `repown guard on \| off \| status` | install, remove or show the pre-push hook |
167
- | `repown accounts list \| add \| remove` | the accounts this machine knows (`add` takes `--name`, `--email`, `--host github\|azdo\|generic`) |
168
- | `repown scan [dir...] [--emails] [--depth <n>] [--format json]` | audit every clone under the given directories (default: the current one) |
169
-
170
- - **Help:** `repown --help` lists the commands. `repown help <command>` (or
171
- `repown <command> --help`) shows a command's options, and `repown help guard on` goes
172
- one level deeper. Asking for help never changes anything.
173
- - **Every command:** `--cwd <dir>` works on all of them.
174
- - **Scripts:** `repown scan --format json` and `repown accounts list --format json` print
175
- one JSON document on stdout. Those fields are stable; the text layout isn't
176
- ([ADR-014](docs/decisions/ADR-014-json-for-scripts.md)).
177
- - **Version:** `repown --version`.
178
- - **Exit codes:** `0` success, `1` failure or refusal, `2` usage error.
179
-
180
- ## Development
181
-
182
- From a clone (`npm link` puts your working copy on PATH as `repown`):
183
-
184
- ```
185
- git clone https://github.com/makubexD/repown.git
186
- cd repown && npm install && npm run build && npm link
187
- npm test # node's own test runner, no framework
188
- npm run build # tsc, also the typecheck
189
- ```
190
-
191
- Cutting a version (maintainers):
192
-
193
- ```
194
- npm run changelog # draft CHANGELOG.md's Unreleased section from git history, then edit it
195
- npm run release:patch # or release:minor | release:major | release:beta
196
- git push --follow-tags # CI publishes to npm (trusted publishing) and creates the GitHub Release
197
- ```
198
-
199
- `release:*` runs `npm version`, which refuses unless the repository is ready
200
- (`npm run release:check`), the tests and build pass, and the tarball has the files it
201
- needs and none it mustn't ship (`npm run pack:check`). It then dates the changelog, commits and tags
202
- `v<version>` locally. The whole routine is in [docs/RELEASING.md](docs/RELEASING.md);
203
- what changed in each version is in [CHANGELOG.md](CHANGELOG.md).
204
-
205
- - **Node:** developing needs Node 22.18+, though running needs only 20
206
- ([ADR-010](docs/decisions/ADR-010-typescript-on-node.md)).
207
- - **Dependencies:** zero at runtime, by choice.
208
- - **Demo:** `vhs demo/demo.tape` runs a [VHS](https://github.com/charmbracelet/vhs)
209
- script with placeholder identities in a throwaway sandbox. No GIF is committed yet,
210
- because VHS hasn't rendered on the machines tried so far.
211
- - **Further reading:**
212
- - [CLAUDE.md](CLAUDE.md) has the contributor rules.
213
- - [docs/decisions/](docs/decisions/README.md) explains every non-obvious choice.
372
+ | every scenario, with diagrams | [docs/HOW-IT-WORKS.md](docs/HOW-IT-WORKS.md) |
373
+ | environment variables, where accounts are kept, per-clone keys, scripts and JSON | [docs/CONFIGURATION.md](docs/CONFIGURATION.md) |
374
+ | short answers, and how repown compares with `includeIf`, SSH aliases and `gh auth switch` | [docs/FAQ.md](docs/FAQ.md) |
375
+ | to contribute, see where each feature lives in the code, or try it on throwaway repositories | [CONTRIBUTING.md](CONTRIBUTING.md) |
376
+ | to report a vulnerability privately | [SECURITY.md](SECURITY.md) |
377
+ | why it works this way, one ADR per decision | [docs/decisions/](docs/decisions/README.md) |
378
+ | what changed in each version, and how a release is cut | [CHANGELOG.md](CHANGELOG.md), [docs/RELEASING.md](docs/RELEASING.md) |
214
379
 
215
380
  ## License
216
381