@grant/mgit
v1.1.2
Published
Clone all repos for a GitHub user or organization
Readme
mgit
Clone all repos for a GitHub user or organization.
npm i -g @grant/mgitFeatures
- Clones every repo for a user or org in the current directory
- Skips archived repos (reported in summary)
- Optional
--pullto git pull in existing repos (off by default) - Progress table: new vs existing, per-repo time, total progress with elapsed time
- Configurable timeout per clone (default 5m) with
--timeout=SECONDS; timed-out repos retried at end; slow/skip/fail clearly marked
Commands
mgit clone [owner] # Clone all repos (default: authenticated user)
mgit init [token] # One-time: create ~/.mgit.json with your token
mgit status # List repos cloned for this user/orgclone
Clones every repository at github.com/<owner> (user or org) into the current directory. If you omit owner, it uses the GitHub user for your saved token.
mgit clone # clone all repos for the authenticated user
mgit clone google # clone all of google's repos
mgit clone --pull # clone missing repos and git pull in existing ones
mgit clone --timeout=120 # 2-minute timeout per clone (default: 300)After cloning, mgit writes a .mgit.json file in the current directory with the owner and list of repo names so mgit status knows what you have.
status
Prints the owner and list of repos that were cloned in this directory (from .mgit.json).
mgit status
# grant (42 repos)
# grant/mgit
# grant/other-repo
# ...Setup (one-time)
Create the global config with your GitHub token. Create a token at github.com/settings/tokens (scope: repo), then:
mgit init <your-token>This creates ~/.mgit.json with your token.
Develop
- Install dependencies:
npm install - Install the CLI from this repo (one-time):
npm run build— putsmgiton your PATH using this checkout. - Create global config (one-time):
mgit init <token>— use a GitHub token withreposcope.
Watch: Use two terminals.
- Terminal 1:
npm run dev— recompiles when you save a.tsfile. - Terminal 2:
mgit clone,mgit status, etc. — each run uses the latest code.
Publish (npm)
You can publish from your machine or let the release pipeline publish when you merge a release PR.
Manual publish (from your machine)
- Bump version in
package.json(e.g. set"version": "1.0.1") or runnpm version patch/minor/major. - Build:
npm run build:ci - Log in to npm (one-time per machine):
npm login— enter username, password, and OTP if you use 2FA. - Publish:
npm publish --access public(required for scoped packages like@grant/mgit). With 2FA you’ll be prompted for a one-time password; pass it inline withnpm publish --access public --otp=123456if you prefer.
Then npm i -g @grant/mgit will install the new version.
Automated publish (Release Please + GitHub Actions)
- Conventional commits — Use
fix:,feat:, orfeat!:(breaking) in commit messages so Release Please can bump the version. - Release PR — On push to
main, Release Please opens or updates a release PR (version + CHANGELOG). Merge it to create the GitHub release. - npm — When the release is published, the Publish to npm workflow runs. Configure a trusted publisher on the package’s npm page (Package access → Trusted publishers) so publishing uses OIDC—no token in repo secrets.
After each merged release PR, the new version is on npm and installable with npm i -g @grant/mgit.
Tech
- CLI: commander
- Git: simple-git
- GitHub API: @octokit/rest
