Enable and initialize a GitHub repository's wiki from the terminal — including the "Create the first page" step that normally forces you into the browser. A gh extension, and the wiki sibling of gh-social-upload.
gh extension install ibrews/gh-wiki-init
gh wiki-init init-auth # one-time browser login
gh wiki-init OWNER/REPO ./my-wiki-pages # enable + create first page + push pagesSpinning up a repo's wiki from a script is weirdly hard:
has_wikiis a repo setting (settable via the API), but theOWNER/REPO.wiki.gitrepo doesn't exist until a first page is created — until thengit clone/git pushreturnsremote: Repository not found, even withhas_wikion. (The "justgit pushto init it" trick is a myth.)- And there is no REST/GraphQL API to create a wiki page. So the first page can only be made by submitting GitHub's web form.
So gh wiki-init does the one unavoidable UI step (drive the new-page form via a saved browser session, à la gh social-upload), then does everything else over plain git. After that, git push to .wiki.git works normally.
gh extension install ibrews/gh-wiki-init
# one-time deps for the browser step:
cd "$(gh extension list | grep gh-wiki-init >/dev/null && dirname "$(gh extension exec wiki-init --help >/dev/null 2>&1; echo)")" 2>/dev/null
# simplest: cd into the extension dir and install
cd ~/.local/share/gh/extensions/gh-wiki-init && npm install && npx playwright install chromium chromium-headless-shellThen log in once:
gh wiki-init init-authA Chromium window opens; log into GitHub (2FA included) and it saves the session and closes itself. The session is stored at ~/.local/state/gh-wiki-init/auth/github.json — and if you already use gh-social-upload, its session is reused automatically, so you don't log in twice.
# minimal: enable the wiki + create a Home page pointing at the README
gh wiki-init OWNER/REPO
# seed the wiki from a folder of Markdown pages (must contain Home.md; other *.md become pages)
gh wiki-init OWNER/REPO ./wiki-pagesIdempotent: if the wiki already has pages, your pages are merged in (clone → copy → push); if it's empty, the first page is created for you first.
- Stand up a wiki in one command.
gh wiki-init init-authonce, thengh wiki-init your/repo ./pages— the wiki goes from "doesn't exist" to live, no browser clicking. - Seed real pages. Make a
pages/folder withHome.md,Getting-Started.md,FAQ.md, thengh wiki-init your/repo ./pages— each.mdbecomes a wiki page (GitHub uses the filename, dashes → spaces). - Use it in CI. After
gh wiki-init init-authon a machine once (session persists for weeks), a job can regenerate wiki pages andgh wiki-initthem on every push — no human in the loop. - Re-seed an existing wiki. Point it at a repo whose wiki already exists; it clones, overlays your pages, and pushes — handy for keeping a wiki in sync from a docs folder in your main repo.
- Pair it with
gh-social-upload. Both automate the GitHub web-UI-only steps (wiki first page / social-preview image). Install both and a fresh repo is "public-ready" from the terminal.
gh wiki-init OWNER/REPO pages_dir
│
├─ gh api PATCH repos/OWNER/REPO has_wiki=true (enable the feature)
├─ git ls-remote …wiki.git → initialized?
│ └─ no → Playwright opens …/wiki/_new, fills the gollum form, "Save page" (first page)
└─ git clone …wiki.git → copy your pages → git push (your pages)
The browser step uses a saved Playwright session (Chromium, headless) and only touches the new-page form. The git steps use your gh auth token.
- macOS/Linux (uses
gh,git, and Playwright's Chromium). - The session can expire (~weeks); if a run reports it's logged out, re-run
gh wiki-init init-auth. - GitHub's wiki form has anti-spam timing + a honeypot field; the tool waits a beat before submitting and never fills the honeypot.
- No token is embedded in any committed file; git auth uses
gh auth tokenat run time (and is redacted from error output).
MIT © Alex Coulombe. Not affiliated with GitHub.