Skip to content

Guide · Open source

How to use gitingest: install, run and feed repos to an LLM

Updated · written with AI from the project's own documentation and checked against our catalogue data

Gitingest turns a Git repository, a GitHub URL or a local directory into a single text digest that you can paste into a large language model prompt. The digest includes a file tree and summary statistics such as size and token count. This guide shows you how to install it, run it from the command line or Python, handle private repositories and self-host it with Docker.

Gitingestcoderamp-labs/gitingest · ★ 16.1k · MIT

Quick start

  1. 1Install the package. Run pip install gitingest, or pipx install gitingest if you want the CLI isolated. You need Python 3.8 or newer.
  2. 2Pick a source. Choose a local directory, a repository URL or a subdirectory URL to analyse.
  3. 3Add a token for private repos. Create a GitHub Personal Access Token and pass it with --token or the GITHUB_TOKEN environment variable.
  4. 4Run the command. Run gitingest followed by your source. The digest is written to digest.txt unless you set --output.
  5. 5Adjust the output. Use --output to choose a file, or -o - to send the digest to STDOUT for piping. Add --include-gitignored if you need ignored files.
  6. 6Paste into your prompt. Open the digest file and paste its contents into your AI assistant along with your question.

What gitingest does and who it is for

Gitingest reads a repository and writes out its contents as one text digest. The README describes the output as formatted for LLM prompts, and it includes a file and directory structure, the size of the extract and a token count.

It suits developers who want an AI assistant to see a codebase, and people who need a quick overview of a repository they did not write. The README also notes that you can replace hub with ingest in any GitHub URL to get the digest from the website.

  • Input: a Git repository URL, a local directory or a subdirectory of a repository
  • Output: one text digest with a file tree, summary statistics and file contents
  • Interfaces: a command line tool, a Python package, the website and Docker self-hosting

Install gitingest with pip or pipx

Gitingest is available on PyPI and requires Python 3.8 or newer. You can install it with pip. The README suggests pipx is a good idea, particularly for the command line tool, and says you can install pipx with your preferred package manager.

If you use pipx for the first time, run the ensurepath command after installing pipx.

  • Python 3.8+ is required
  • pipx is optional but recommended for the CLI
  • Use pip install gitingest[server] if you want the server dependencies for self-hosting
pip install gitingest pipx install gitingest pipx ensurepath

Run gitingest from the command line

The gitingest command analyses a codebase and creates a text dump of its contents. Pass it a local path or a repository URL. By default the digest is written to digest.txt in your current working directory.

You can write to a named file with --output or -o. Use -o - to send the output to STDOUT, which is useful when piping to other tools. Run gitingest --help to see more options.

  • --output/-o <filename> writes to a specific file
  • --output/-o - writes to STDOUT
  • By default, files listed in .gitignore are skipped; use --include-gitignored to keep them
# Basic usage (writes to digest.txt by default) gitingest /path/to/directory # From URL gitingest https://github.com/coderamp-labs/gitingest # or from specific subdirectory gitingest https://github.com/coderamp-labs/gitingest/tree/main/src/gitingest/utils

Use gitingest with a private repository

Private repositories need a GitHub Personal Access Token (PAT). The README links to a page where you can generate one. Pass the token with --token or -t, or set the GITHUB_TOKEN environment variable and run the command without the flag.

The README also shows how to include repository submodules with --include-submodules.

  • Option 1: --token/-t with your token
  • Option 2: export GITHUB_TOKEN before running the command
  • Option 3: --include-submodules to include submodules
gitingest https://github.com/username/private-repo --token github_pat_... export GITHUB_TOKEN=github_pat_... gitingest https://github.com/username/private-repo gitingest https://github.com/username/repo-with-submodules --include-submodules

Use gitingest from Python

Import the ingest function to get the digest in your own code. It returns three values: a summary, a tree and the content. The same functions accept local paths and URLs, and you can pass a token as a parameter or through the environment.

The README notes that the synchronous function does not write a file by default, and that file output can be enabled with the output argument. For async code, use ingest_async. In Jupyter notebooks, the README says to await ingest_async directly, because notebooks are asynchronous by default.

  • ingest(path_or_url) returns summary, tree, content
  • ingest(url, token=...) passes a token directly
  • ingest(url, include_submodules=True) includes submodules
  • ingest_async for async code and Jupyter notebooks
from gitingest import ingest summary, tree, content = ingest("path/to/directory") summary, tree, content = ingest("https://github.com/coderamp-labs/gitingest") from gitingest import ingest_async import asyncio result = asyncio.run(ingest_async("path/to/directory"))

Self-host gitingest with Docker

The README gives Docker steps for hosting your own instance. Build the image from the repository, then run the container on port 8000. The application is then available at http://localhost:8000.

If you host it on a domain, set the ALLOWED_HOSTS environment variable to the hostnames you want to allow. The README lists the default as gitingest.com, *.gitingest.com, localhost and 127.0.0.1. Other environment variables cover the Prometheus metrics server and Sentry.

  • ALLOWED_HOSTS: comma-separated list of allowed hostnames
  • GITINGEST_METRICS_ENABLED: enables the Prometheus metrics server when set
  • GITINGEST_METRICS_HOST and GITINGEST_METRICS_PORT: default 127.0.0.1 and 9090
  • GITINGEST_SENTRY_ENABLED: enables Sentry
docker build -t gitingest . docker run -d --name gitingest -p 8000:8000 gitingest ALLOWED_HOSTS="example.com, localhost, 127.0.0.1"

What people use it for

  • Give an AI coding assistant context about a repository before asking it to refactor code
  • Get a quick overview of an unfamiliar open-source project by reading its file tree and digest
  • Pipe the digest to another command-line tool using -o -
  • Load a repository or subdirectory from a Python notebook with ingest_async
  • Host a private instance on your own server with Docker

Frequently asked questions

Is gitingest free to use?

The project is licensed under the MIT licence, as shown in the repository. The README does not list any paid tier, so the source supports free use under that licence. Check the LICENSE file in the repository for the full terms.

How do I install gitingest?

Run pip install gitingest, or pipx install gitingest if you want it isolated for the command line. Gitingest needs Python 3.8 or newer. The README suggests pipx for the CLI.

Can gitingest access private repositories?

Yes, but you need a GitHub Personal Access Token. Pass it with --token or -t, or set the GITHUB_TOKEN environment variable. Without a token, private repositories cannot be read.

Does gitingest skip files in .gitignore?

Yes. By default, files listed in .gitignore are skipped. Add --include-gitignored if you need them in the digest.

Where does the output go?

By default the command writes a file called digest.txt in your current directory. Use --output or -o to choose a file name, or -o - to print to STDOUT.

How does gitingest compare with repomix or code2prompt?

Repomix, files-to-prompt and code2prompt are comparable projects that also turn code into prompt-ready text. This README does not compare them with gitingest, so check each project's documentation to see which options and output formats fit your workflow.

New agent skills, repos and AI tools — every week

The best new skills and open-source projects, the fastest-growing repos, and one free prompt. Five minutes to read. Unsubscribe anytime.

Our verdict

Gitingest is a good fit if you want a quick, prompt-ready digest of a repository from the command line, from Python or from a GitHub URL. Private repositories need a token, and if you need fine-grained control over which files are included, check the documentation carefully or compare it with alternatives such as repomix.

Install options & downloads