Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/addyosmani/git2txt
CLI tool to convert GitHub repositories to text files for LLMs
https://github.com/addyosmani/git2txt
cli convert git github llm repository text
Last synced: about 6 hours ago
JSON representation
CLI tool to convert GitHub repositories to text files for LLMs
- Host: GitHub
- URL: https://github.com/addyosmani/git2txt
- Owner: addyosmani
- License: mit
- Created: 2024-11-21T00:41:06.000Z (2 months ago)
- Default Branch: main
- Last Pushed: 2024-11-22T03:20:51.000Z (2 months ago)
- Last Synced: 2025-01-20T07:55:22.726Z (4 days ago)
- Topics: cli, convert, git, github, llm, repository, text
- Language: JavaScript
- Homepage:
- Size: 107 KB
- Stars: 438
- Watchers: 4
- Forks: 40
- Open Issues: 10
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# git2txt
Convert GitHub repositories to text files with ease. This CLI tool downloads a repository and concatenates its contents into a single text file, making it perfect for analysis, documentation, or AI training purposes.
![Screenshot](https://github.com/user-attachments/assets/846fcec4-5919-44c7-956d-ca0ee6384c77)
## Features
- 📥 Download any public GitHub repository
- 📝 Convert repository contents to a single text file
- ⚡ Automatic binary file exclusion
- 🔧 Configurable file size threshold
- 💻 Cross-platform support (Windows, macOS, Linux)## Installation
```bash
npm install -g git2txt
```## Usage
You can specify the repository in several formats:
```bash
# Full HTTPS URL
git2txt https://github.com/username/repository# Short format (username/repository)
git2txt username/repository# SSH format
git2txt [email protected]:username/repository
```### URL Format Support
The tool accepts these GitHub repository URL formats:
- HTTPS URLs: `https://github.com/username/repository`
- Short format: `username/repository`
- SSH URLs: `[email protected]:username/repository`
- URLs with or without `.git` suffix
- URLs with or without trailing slashes### Options
```
--output, -o Specify output file path (default: repo-name.txt)
--threshold, -t Set file size threshold in MB (default: 0.1)
--include-all Include all files regardless of size or type
--debug Enable debug mode with verbose logging
--help Show help
--version Show version
```### Examples
Download and convert a repository using different formats:
```bash
# Using HTTPS URL
git2txt https://github.com/username/repository# Using short format
git2txt username/repository# Using SSH URL
git2txt [email protected]:username/repository# With custom output file
git2txt username/repository --output=output.txt# With custom file size threshold (2MB)
git2txt username/repository --threshold=2# Include all files (no size/type filtering)
git2txt username/repository --include-all# Enable debug output
git2txt username/repository --debug
```## Default Behavior
- Files larger than 100KB are excluded by default
- Binary files are automatically excluded
- The output file is created in the current directory named after the repository
- Files are processed recursively through all subdirectories (excluding node_modules and .git)
- File paths and contents are separated by clear markers
- Relative paths are preserved in the output## Output Format
The tool generates a text file with this format:
```
================================================================================
File: path/to/file.txt
Size: 1.2 KB
================================================================================[File contents here]
================================================================================
File: another/file.js
Size: 4.5 KB
================================================================================[File contents here]
```## Contributing
Contributions are welcome! Please see our [Contributing Guide](CONTRIBUTING.md) for details.
## License
MIT