Skip to main content

gitin - GitHub Repository Content Extractor

PyPI version License: MIT Python Versions

A command-line tool designed to extract and format GitHub repository content for effective use with Large Language Models (LLMs). Perfect for providing codebases as context in LLM conversations.

Features

  • 🔍 Smart Extraction: Extract files based on patterns and content
  • 📝 LLM-Optimized: Clean markdown output with token estimation
  • 🚀 Progress Tracking: Visual progress bars for operations
  • 🎯 Flexible Filtering: Include/exclude patterns and content search
  • 📊 Size Control: File size limits and statistics
  • 🔄 Version Control: Respects .gitignore rules

Installation

pip install gitin

From Source

git clone https://github.com/unclecode/gitin
cd gitin
pip install -e .

Quick Start

# Basic usage
gitin https://github.com/username/repo -o output.md

# Extract Python files only
gitin https://github.com/username/repo --include="*.py" -o python_files.md

# Search for specific content
gitin https://github.com/username/repo --search="TODO,FIXME" -o review.md

Advanced Usage

Code Review Workflow

# Extract implementation files, excluding tests
gitin https://github.com/username/repo \
  --include="src/*.py" \
  --exclude="test_*,*_test.py" \
  --search="TODO,FIXME,HACK" \
  -o code_review.md

Feature Analysis

# Find async/await usage
gitin https://github.com/username/repo \
  --include="*.py,*.js" \
  --search="async def,await" \
  -o async_patterns.md

Documentation Extraction

# Get all documentation files
gitin https://github.com/username/repo \
  --include="docs/*,*.md,*.rst" \
  --exclude="**/tests/*" \
  -o documentation.md

Command-Line Options

Options:
  --version           Show the version and exit.
  --exclude TEXT      Comma-separated glob patterns to exclude
                     Example: --exclude="test_*,*.tmp,docs/*"
  --include TEXT      Comma-separated glob patterns to include
                     Example: --include="*.py,src/*.js,lib/*.rb"
  --search TEXT       Comma-separated strings to search in content
                     Example: --search="TODO,FIXME,HACK"
  --max-size INTEGER  Maximum file size in bytes (default: 1MB)
  -o, --output TEXT   Output markdown file path [required]
  --help             Show this message and exit.

LLM Integration Tips

  1. Context Window Management

    • Check the token count in the summary
    • Use --max-size to limit file sizes
    • Use --search to focus on relevant sections
  2. Effective Filtering

    • Use --include for specific file types
    • Use --exclude to remove noise
    • Combine with --search for precise results
  3. Best Practices

    # Extract core functionality
    gitin https://github.com/org/repo \
      --include="src/**/*.py" \
      --exclude="**/*test*" \
      --max-size=50000 \
      -o core_logic.md
    

Contributing

Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Changelog

See CHANGELOG.md for release history.

Release files for gitin 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for gitin 0.1.0
File Size Uploaded
gitin-0.1.0.tar.gz 6.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for gitin 0.1.0
File Interpreter ABI Platform
gitin-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 12.7 kB

Release files / gitin-0.1.0.tar.gz

Download URL gitin-0.1.0.tar.gz
Size 6.2 kB
Tags Source
SHA-256 checksum
How to use checksums
ea4aa27d6d6afcec5ceb1e60fac237ed75331b88d6488366be93995ee1563783
BLAKE2b-256 checksum
How to use checksums
f3ab8dc1a2d9ac9be8633ec09966a476203632646104ab58016122506ba33ff2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.10.13

Release files / gitin-0.1.0-py3-none-any.whl

Download URL gitin-0.1.0-py3-none-any.whl
Size 6.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
055de2b7e911bb22b0053ebf5a76c889788ecb75bb1da7d2317e5480e2360886
BLAKE2b-256 checksum
How to use checksums
d4f0a964d978a11d3b7be3d78762c2750198dbc1579354d901cd8c450a18c20f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.10.13

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page