repo2text is a Rust CLI tool designed to transform the contents of a Git repository into a structured text file. This is particularly useful for uploading repository data into AI systems (like ChatGPT) for analysis, summarization, or debugging purposes.
- Recursively traverses a Git repository to extract file contents.
- Appends the file paths and contents into a single
.txt
file. - Formats the output with clear delimiters for AI compatibility.
- Skips binary files and handles missing files gracefully.
Install the tool using cargo
:
cargo install repo2text
Or clone the repository and build from source:
git clone /~https://github.com/vicentedpsantos/repo2text.git
cd repo2text
cargo build --release
Run repo2text
with the following options:
repo2text --repo <REPO_PATH> --output <OUTPUT_FILE> --excluding <EXCLUDED_DIR>
--repo
: required. Path to the root of the Git repository.--output
: required. Path to the output.txt
file where the repository contents will be saved.--excluding
: optional. Directory to exclude from the traversal. Can be used multiple times.
repo2text --repo ~/projects/faktur --output faktur.txt
repo2text --repo ~/projects/faktur \
--output ~/temp/faktur.txt \
--excluding ~/projects/faktur/spec/ \
--excluding ~/projects/faktur/.git/
This command will:
- Traverse the repository at
~/projects/faktur
. - Read the contents of committed files while excluding the specified directories.
- Save the structured data to
faktur.txt
.
The tool generates a .txt
file where:
- Each file begins with a
FILE_PATH
line indicating its location in the repository. - File contents are enclosed within a code block (
```<language>
...
```
). - Sections are separated by
---
for easy parsing.
The structured format makes it easy to share your repository with AI systems for:
- Code analysis or debugging.
- Generating documentation or summaries.
- Discussing code architecture or functionality.
Simply copy and paste sections of the output .txt
file into your AI chat or upload the entire file if supported.
- Excludes uncommitted changes or ignored files.
- Binary files are skipped to prevent unreadable output.
This project is licensed under the MIT License.