gitFM is a modern, developer-first command-line utility for discovering, exploring, and cloning GitHub and GitLab repositories directly from your terminal. Whether you want to quickly clone a single subfolder of a massive monorepo or browse repos interactively without ever leaving your shell, gitFM has you covered.
- β‘ Advanced Partial Cloning: Clone massive repositories without downloading gigabytes of history or files. Supports Shallow, Blobless, Treeless, and Sparse-checkout cloning out of the box.
- π Interactive Monorepo Navigation: Search remote repositories and browse remote directory trees interactively to pick exactly which folder to clone.
- π Headless GitHub OAuth Device Flow: Seamless browser passcode login without dealing with client secrets or copy-pasting tokens, plus personal access token (PAT) fallback.
- π¦ First-Class GitLab Integration: Authenticate, verify token validity, rotate personal access tokens with custom expiration dates, and revoke tokens in one command.
- π Rich Terminal Search (
ghs): Tabular search of public, private, or starred repositories by user, language, topic, or README contents. - π‘οΈ Sanitization & Safety: Strict URL validation, directory traversal prevention, ref validation, and safe process execution to protect against command injection.
- π¨ Delightful CLI UX: Rich colors, interactive autocomplete prompts, and dynamic ASCII headers powered by
chalk,cfonts, and@inquirer.
Ensure you have Node.js (>= 20) and Git installed on your system.
npm install -g gitfmYou can run commands without installing globally:
npx gitfm clone <REPO_URL> [options]To display the main help menu and view all available commands:
gitfm --helpTo get detailed instructions and options for any individual command:
gitfm help <command-name>
# Example:
gitfm help cloneNote
In command help specifications, arguments wrapped in <> are mandatory, while arguments wrapped in [] are optional.
Clone remote Git repositories using normal or partial cloning strategies. No authentication is required for public repositories.
gitfm clone <REPO_URL> [DIRNAME] [BRANCHNAME] [CONE_MODE] [options]<REPO_URL>: (Mandatory) The URL of the remote Git repository (https://,ssh://, orgit@).[DIRNAME]: Target directory name. If omitted, defaults to the repository name.[BRANCHNAME]: Remote branch to checkout.[CONE_MODE]:coneornocone(default:nocone). Used with sparse checkout.
| Flag | Description |
|---|---|
--sparse <PATHS...> |
Clone only the specified director(y|ies) or file(s) (sparse checkout). |
--shallow |
Shallow clone only the latest commit (--depth 1). |
--blobless |
Blobless clone (--filter=blob:none) β downloads commits and trees, fetches file contents on demand. |
--treeless |
Treeless clone (--filter=tree:0) β fetches tree objects and blobs only when needed. |
# Normal clone
gitfm clone https://github.com/facebook/react.git
# Shallow clone of latest commit
gitfm clone https://github.com/torvalds/linux.git linux-shallow --shallow
# Blobless clone (optimal for large repos with heavy commit history)
gitfm clone https://github.com/microsoft/vscode.git vscode-blobless --blobless
# Sparse clone of a specific directory in a monorepo
gitfm clone https://github.com/vercel/next.js.git nextjs-examples --sparse examplesTip
Read the GitHub blog guide on partial and shallow clones to learn when to use blobless vs. treeless vs. shallow cloning.
Interactively search repositories, explore directory trees, and choose cloning preferences on the fly.
gitfm icl [options]| Flag | Description |
|---|---|
--gh |
Interactively search and clone a GitHub repository (authenticated with partial cloning support). |
--gl |
Interactively search and clone a GitLab project. |
-u, --unauthenticated |
Legacy GitHub interactive search and clone (does not require authentication). |
- Enter your search query.
- Select a repository from the autocomplete list.
- Review repository metadata (name, description, URL).
- Choose clone format: Normal or Partial (
shallow,blobless,treeless, orsparse). - In Sparse mode, navigate folders interactively to select exactly what you want to pull down.
Manage GitHub authorization and check your user overview.
gitfm gh [options]| Flag | Description |
|---|---|
--auth [TYPE] |
Authorize gitFM with GitHub. Arguments: web (OAuth Device Flow) or token (PAT). Prompts interactively if omitted. |
--profile |
Display a terminal summary card of your authenticated profile. |
- Web Login (OAuth Device Flow): Displays your one-time user code, automatically opens your browser window for verification, and listens for authorization approval. Read the author's article on integrating GitHub Device Flow in CLI apps to understand how this works securely without client secrets.
- Token Login (PAT): Authenticate with a personal access token requiring
repoanduserscopes. - Tokens are safely encoded and stored locally in
~/.gitfmrc.json.
Authenticate and manage tokens for GitLab.
gitfm gl [options]| Flag | Description |
|---|---|
--login |
Log in with a GitLab Personal Access Token (requires api scope). |
--logout |
Revoke the active token on GitLab and clear stored credentials. |
--rotate <EXPIRY_DATE> |
Rotate the active personal access token with a new expiration date (YYYY-MM-DD). |
# Log in to GitLab
gitfm gl --login
# Rotate current token with a new expiration date
gitfm gl --rotate 2026-12-31
# Logout and revoke token
gitfm gl --logoutSearch GitHub repositories with rich filters and formatted table outputs.
gitfm ghs [TERM] [options]| Flag | Description |
|---|---|
--me |
Show only repositories owned by the authenticated user. |
-p, --private |
Show only private repositories owned by the authenticated user. |
-s, --starred |
Show repositories starred by the authenticated user. |
-u, --user <USER> |
Show repositories owned by the specified username. |
-l, --language <LANG> |
Show repositories matching TERM written in the given language. |
-t, --topic |
Show repositories matching TERM in topic tags. |
-r, --readme |
Show repositories matching TERM within README files. |
# Search repositories by keyword
gitfm ghs cli-utility
# List your own repositories
gitfm ghs --me
# Search TypeScript repositories matching "compiler"
gitfm ghs compiler -l typescript
# Search by topic
gitfm ghs devops --topic
# List your starred repositories
gitfm ghs --starred- GitHub OAuth Device Flow: gitFM never handles client secrets. Authentication uses the OAuth 2.0 Device Authorization Grant (RFC 8628), keeping your GitHub credentials secure.
- Local Dotfiles: Credentials are encrypted/encoded and stored in user home directory dotfiles (
~/.gitfmrc.jsonand~/.gl.gitfmrc.json). - Input Sanitization: All user inputs (URLs, file paths, directory targets, branch names, and dates) are rigorously validated to prevent shell injection, path traversal, or command abuse.
- Safe Subprocesses: System commands are executed via safe argument arrays (
execFile) rather than unsanitized shell execution.
gitFM is written in TypeScript and follows the Result Object Pattern for robust, contextual error handling without unexpected runtime crashes.
# Build the TypeScript project to dist/
npm run build
# Run ESLint (using Flat Config + typescript-eslint + unicorn rules)
npm run lintgitFM/
βββ assets/img/ # Help screenshots and images
βββ src/
β βββ cloning.ts # Git execution (normal, shallow, blobless, treeless, sparse)
β βββ constants.ts # Cloning options definitions
β βββ index.ts # Commander CLI command registration and dispatch
β βββ pattern.ts # Result<T, E> functional error handling pattern
β βββ sanitize.ts # Input validation and security sanitizers
β βββ token-storage.ts # DRY token reading, saving, and management
β βββ ui.ts # Terminal UI, banners, search prompts, and table formatters
β βββ gh/ # GitHub integration
β β βββ api.ts # Octokit REST queries & rate limit checks
β β βββ auth.ts # Device Flow OAuth & PAT verification
β β βββ config.ts # GitHub Client ID and scope configs
β β βββ interactive-clone.ts # GitHub interactive clone workflows
β βββ gl/ # GitLab integration
β βββ api.ts # GitLab v4 API requests, token rotation, and tree navigation
β βββ config.ts # GitLab API configs
β βββ interactive-clone.ts # GitLab interactive clone workflows
βββ eslint.config.ts # ESLint flat config with unicorn kebab-case rules
βββ tsconfig.json # TypeScript ES2022 / NodeNext compiler configuration
βββ package.json
Have an issue, feature request, or suggestion? Please open an issue in the GitHub Repository.
If you find gitFM helpful, consider giving it a star on GitHub. It helps more developers discover the project!
This project is licensed under the ISC License.

