🤖 AI-Assisted Development: This project was developed with assistance from Claude (Anthropic) for rapid prototyping and code generation.
A powerful CLI tool to extract and clone repositories from GitHub Enterprise organizations, with full support for SAML-authenticated environments.
- 🔐 SAML Authentication - Full support for GitHub Enterprise SAML-enabled organizations
- 📦 Batch Operations - Download all repositories or select specific ones
- 🎯 Interactive Selection - Choose repositories from an interactive checkbox list
- 🔒 Multiple Auth Methods - Personal Access Tokens with SSO support
- ⚡ Performance - Shallow clone support for faster downloads
- 🌐 GitHub Enterprise - First-class support for Enterprise instances
- 🔧 Flexible Options - SSH/HTTPS protocols, custom output directories
- Installation
- Quick Start
- Commands
- Authentication
- Usage Examples
- GitHub Enterprise
- Development
- Testing
- Contributing
- License
git clone https://github.com/yourusername/github-extractor.git
cd github-extractor
npm install
npm run build
npm linknpm install -g github-extractor# 1. Authenticate
gh-extract login
# 2. Extract repositories interactively
gh-extract extract your-org-name
# 3. Or download all repositories
gh-extract extract your-org-name --allAuthenticate with GitHub using a Personal Access Token.
Options:
-u, --url <url>- GitHub Enterprise API base URL (e.g.,https://github.company.com/api/v3)
Example:
# GitHub.com
gh-extract login
# GitHub Enterprise
gh-extract login --url https://github.company.com/api/v3Extract and clone repositories from an organization.
Arguments:
<organization>- GitHub organization name
Options:
-a, --all- Download all repositories without prompting-o, --output <dir>- Output directory (default:./repositories)--ssh- Use SSH for cloning instead of HTTPS--shallow- Perform shallow clone (depth=1)--base-url <url>- GitHub Enterprise base URL
Examples:
# Interactive selection
gh-extract extract my-org
# Download all repositories
gh-extract extract my-org --all
# Custom output directory with SSH
gh-extract extract my-org --all --output ~/repos --ssh
# Shallow clone for faster download
gh-extract extract my-org --all --shallow
# GitHub Enterprise
gh-extract extract my-org --base-url https://github.company.com/api/v3List all repositories in an organization without downloading.
Options:
--base-url <url>- GitHub Enterprise base URL--json- Output as JSON
Examples:
# Human-readable list
gh-extract list my-org
# JSON output for scripting
gh-extract list my-org --json > repos.jsonShow current authentication status.
gh-extract statusClear saved authentication credentials.
gh-extract logoutThis tool uses Personal Access Tokens (PATs) for authentication, which work seamlessly with SAML-enabled organizations.
Navigate to token settings:
- GitHub.com: https://github.com/settings/tokens/new
- GitHub Enterprise:
https://your-github-enterprise.com/settings/tokens/new
Configure the token:
- Description:
GitHub Extractor - Scopes: Select
repoandread:org - Expiration: Choose based on your security policy
- Description:
Generate the token
Important: For SAML-enabled organizations, you must authorize your token for SSO:
- After creating the token, go to https://github.com/settings/tokens
- Find your token in the list
- Click "Configure SSO" next to the token
- Click "Authorize" next to your organization
- Confirm the authorization
Note: You must authorize the token for SSO before using it with this tool. Existing tokens cannot be retrofitted with SSO authorization - you must create a new token if you forget this step.
Run gh-extract login and paste your token when prompted. The token is securely stored in your system's configuration directory.
gh-extract extract my-org --all --output ~/backups/my-orggh-extract extract my-org
# Follow prompts to select specific repositoriesgh-extract extract my-org --all --sshgh-extract extract my-org --all --shallow# Login to Enterprise instance
gh-extract login --url https://github.company.com/api/v3
# Extract repos
gh-extract extract my-enterprise-org --all- Determine your GitHub Enterprise API endpoint (typically
https://your-domain.com/api/v3) - Use the
--urlor--base-urloption with all commands - Ensure your PAT has the correct scopes and SSO authorization
# Login
gh-extract login --url https://github.company.com/api/v3
# List organizations (verify access)
gh-extract list my-org --base-url https://github.company.com/api/v3
# Extract repositories
gh-extract extract my-org --all --base-url https://github.company.com/api/v3- Node.js >= 16.0.0
- npm or yarn
# Clone the repository
git clone https://github.com/yourusername/github-extractor.git
cd github-extractor
# Install dependencies
npm install
# Run in development mode
npm run dev -- extract my-org
# Build
npm run build
# Link for local testing
npm linknpm run build- Build TypeScript to JavaScriptnpm run dev- Run in development modenpm test- Run testsnpm run test:watch- Run tests in watch modenpm run test:coverage- Run tests with coveragenpm run lint- Lint codenpm run lint:fix- Fix linting issuesnpm run format- Format code with Prettiernpm run format:check- Check code formatting
# Run all tests
npm test# Run with coverage
npm run test:coverage
# Watch mode for development
npm run test:watchContributions are welcome! Please see CONTRIBUTING.md for details.
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes
- Run tests (
npm test) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- AI Development: This project was developed with assistance from Claude (Anthropic)
- GitHub API: Built using @octokit/rest
- Community: Thanks to all contributors and users
Problem: "Invalid token" error
Solution:
gh-extract logout
gh-extract login
# Create a new token and ensure it has the correct scopesProblem: "Resource protected by organization SAML enforcement"
Solution:
- Visit https://github.com/settings/tokens
- Click "Configure SSO" next to your token
- Authorize your organization
- Create a new token (old one won't work)
- Run
gh-extract logoutandgh-extract loginwith the new token
Problem: GitHub API rate limits
Solution:
- Wait for the rate limit to reset (shown in error message)
- Use a token (authenticated requests have higher limits)
- For GitHub Enterprise, contact your admin
Problem: "Organization not found or you don't have access"
Solution:
- Verify you're a member of the organization
- Check that your token has
read:orgscope - For SAML orgs, ensure SSO authorization is complete
- Issues:GitHub Issues
- Discussions:GitHub Discussions
- Support for GitHub GraphQL API
- Parallel repository cloning
- Archive export format (zip/tar)
- Repository filtering by criteria
- Progress persistence and resume capability
- Docker support
Made with ❤️ and 🤖 AI assistance