Skip to content

nkbud/git-explorer

Β 
Β 

Gitingest

Image

License PyPI version GitHub stars Downloads

Discord

Turn any Git repository into a prompt-friendly text ingest for LLMs.

You can also replace hub with ingest in any GitHub URL to access the corresponding digest.

gitingest.com Β· Chrome Extension Β· Firefox Add-on

πŸš€ Features

  • Easy code context: Get a text digest from a Git repository URL or a directory
  • Smart Formatting: Optimized output format for LLM prompts
  • Statistics about:
    • File and directory structure
    • Size of the extract
    • Token count
  • CLI tool: Run it as a shell command
  • Python package: Import it in your code

πŸ“š Requirements

πŸ“¦ Installation

Gitingest is available on PyPI. You can install it using pip:

pip install gitingest

However, it might be a good idea to use pipx to install it. You can install pipx using your preferred package manager.

brew install pipx
apt install pipx
scoop install pipx
...

If you are using pipx for the first time, run:

pipx ensurepath
# install gitingest
pipx install gitingest

🧩 Browser Extension Usage

Available in the Chrome Web Store Get The Add-on for Firefox Get from the Edge Add-ons

The extension is open source at lcandy2/gitingest-extension.

Issues and feature requests are welcome to the repo.

πŸ’‘ Command line usage

The gitingest command line tool allows you to analyze codebases and create a text dump of their contents.

# Basic usage (writes to digest.txt by default)
gitingest /path/to/directory

# From URL
gitingest https://github.com/cyclotruc/gitingest

# or from specific subdirectory
gitingest https://github.com/cyclotruc/gitingest/tree/main/src/gitingest/utils

For private repositories, use the --token/-t option.

# Get your token from https://github.com/settings/personal-access-tokens
gitingest https://github.com/username/private-repo --token github_pat_...

# Or set it as an environment variable
export GITHUB_TOKEN=github_pat_...
gitingest https://github.com/username/private-repo

By default, the digest is written to a text file (digest.txt) in your current working directory. You can customize the output in two ways:

  • Use --output/-o <filename> to write to a specific file.
  • Use --output/-o - to output directly to STDOUT (useful for piping to other tools).

See more options and usage details with:

gitingest --help

🐍 Python package usage

# Synchronous usage
from gitingest import ingest

summary, tree, content = ingest("path/to/directory")

# or from URL
summary, tree, content = ingest("https://github.com/cyclotruc/gitingest")

# or from a specific subdirectory
summary, tree, content = ingest("https://github.com/cyclotruc/gitingest/tree/main/src/gitingest/utils")

For private repositories, you can pass a token:

# Using token parameter
summary, tree, content = ingest("https://github.com/username/private-repo", token="github_pat_...")

# Or set it as an environment variable
import os
os.environ["GITHUB_TOKEN"] = "github_pat_..."
summary, tree, content = ingest("https://github.com/username/private-repo")

By default, this won't write a file but can be enabled with the output argument.

# Asynchronous usage
from gitingest import ingest_async
import asyncio

result = asyncio.run(ingest_async("path/to/directory"))

Jupyter notebook usage

from gitingest import ingest_async

# Use await directly in Jupyter
summary, tree, content = await ingest_async("path/to/directory")

This is because Jupyter notebooks are asynchronous by default.

πŸ› οΈ Local Development

Prerequisites

  • Python 3.8+ (Python 3.12 recommended)
  • Git (required for repository cloning)
  • Node.js (optional, for frontend development)

Setup

  1. Clone the repository:

    git clone https://github.com/cyclotruc/gitingest.git
    cd gitingest
  2. Create and activate a virtual environment:

    python -m venv venv
    source venv/bin/activate  # On Windows: venv\Scripts\activate
  3. Install dependencies:

    pip install -r requirements.txt
    pip install -r requirements-dev.txt  # For development tools
  4. Set up environment variables (optional):

    # Create a .env file for local configuration
    echo "GITHUB_TOKEN=your_github_token_here" > .env
    echo "ALLOWED_HOSTS=localhost,127.0.0.1" >> .env

Running the Development Server

Start the FastAPI development server:

# From the project root directory
python -m uvicorn server.main:app --host 127.0.0.1 --port 8000 --reload

The application will be available at:

  • Main interface: http://localhost:8000
  • Tree Explorer: http://localhost:8000/tree-explorer
  • API Documentation: http://localhost:8000/api
  • Health Check: http://localhost:8000/health

Development Tools

  • Linting: black . && pylint src/
  • Testing: pytest tests/
  • Pre-commit hooks: pre-commit install && pre-commit run --all-files

Features Available in Development

  1. Web Interface: Browse and analyze repositories through the web UI
  2. Tree Explorer: Interactive D3.js visualization of repository structure
  3. CLI Tool: Use gitingest command for local analysis
  4. API Endpoints: RESTful API for programmatic access

Troubleshooting

  • Port already in use: Change the port: --port 8001
  • Rate limiting issues: Increase limits in server/server_utils.py
  • Static files not loading: Ensure you're running from the project root
  • Repository cloning fails: Check your GitHub token and network connectivity

🐳 Self-host

  1. Build the image:

    docker build -t gitingest .
  2. Run the container:

    docker run -d --name gitingest -p 8000:8000 gitingest

The application will be available at http://localhost:8000.

If you are hosting it on a domain, you can specify the allowed hostnames via env variable ALLOWED_HOSTS.

# Default: "gitingest.com, *.gitingest.com, localhost, 127.0.0.1".
ALLOWED_HOSTS="example.com, localhost, 127.0.0.1"

🀝 Contributing

Non-technical ways to contribute

  • Create an Issue: If you find a bug or have an idea for a new feature, please create an issue on GitHub. This will help us track and prioritize your request.
  • Spread the Word: If you like Gitingest, please share it with your friends, colleagues, and on social media. This will help us grow the community and make Gitingest even better.
  • Use Gitingest: The best feedback comes from real-world usage! If you encounter any issues or have ideas for improvement, please let us know by creating an issue on GitHub or by reaching out to us on Discord.

Technical ways to contribute

Gitingest aims to be friendly for first time contributors, with a simple Python and HTML codebase. If you need any help while working with the code, reach out to us on Discord. For detailed instructions on how to make a pull request, see CONTRIBUTING.md.

πŸ› οΈ Stack

Looking for a JavaScript/FileSystemNode package?

Check out the NPM alternative πŸ“¦ Repomix: https://github.com/yamadashy/repomix

πŸš€ Project Growth

Star History Chart

About

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 72.6%
  • Jinja 19.4%
  • JavaScript 7.6%
  • Dockerfile 0.4%