A simple CLI tool that accepts either:
- A GitHub repository URL
- A local folder path
and concatenates all text/code files into a single string output. This can be useful for providing context to LLMs or other tools that need a single “flattened” representation of your codebase.
- Configurable Include/Exclude: Specify which file types to include or exclude using glob patterns.
- Automatic Ignore: By default,
repocatrespects.gitignoreand other ignore files (unless you disable it). - GitHub Repo Cloning: Automatically clones a GitHub repository and concatenates matching files.
- Checkout Specific Branch/Commit/Tag (via
--checkout). - Preserve or Strip Blank Lines (via
--keep-blank-lines). - Optionally Disable Ignore Rules (via
--no-ignore).
If you have Rust (and Cargo) installed:
cargo install repocatAlternatively, clone this repository and run:
cargo build --releaseYour compiled binary will be in the target/release directory.
You may also use the pre-compiled binaries offered in the Release, though support for different platforms may be limited.
repocat --root /path/to/my-project- This will walk the
my-projectfolder, respecting.gitignoreby default. - Includes files matching
*.toml, *.md, *.py, *.rs, *.cpp, *.h, *.hpp, *.c, *.rst, *.txt, *.cuh, *.cu. - Writes all content into
concatenated_output.txt. - By default, root is
.
repocat --root https://github.com/owner/repo- Clones
repofrom GitHub into a temporary folder. - By default, it checks out the default branch (e.g.,
mainormaster). - Gathers all matching files and writes them to
concatenated_output.txt.
repocat --root https://github.com/owner/repo --checkout feature-branchrepocat --root https://github.com/owner/repo --checkout abcd1234- Clones the specified repository, then checks out either a branch named
feature-branchor the commitabcd1234. - Proceeds to gather and concatenate files as usual.
repocat \
--root /path/to/my-project \
--include "*.rs,*.toml" \
--exclude "*.lock,*.bak"- Only gathers
.rsand.tomlfiles, while excluding anything ending with.lockor.bak.
By default, repocat removes blank lines for more compact output. If you want to preserve them:
repocat --root /path/to/my-project --keep-blank-lines- This keeps the blank lines in your final concatenated output.
If you want to include hidden and/or binary files, you can disable all ignore logic:
repocat --root /path/to/my-project --no-ignore- This will cause repocat to walk the folder without ignoring anything.
- Warning: This may significantly increase the size of your output if your project has large binary files or directories like
.git.
repocatuses the ignore crate by default, which means it respects.gitignore,.ignore, and.rgignorefiles, along with hidden file filtering and binary file detection.- The default list of “included” file extensions can be found in
src/lib.rs, but can be overridden via the--includeand--excludeflags. - If you prefer to keep blank lines in your concatenated output, use
--keep-blank-lines. Otherwise, empty lines are removed.
- JSON Output: A possible future feature to output file metadata and content in a structured JSON format.
- Partial Extraction: Extract only certain lines or only lines matching a pattern.
- Parallel Processing: Speed up concatenation by reading files in parallel.
Thanks for checking out repocat! Feel free to open an issue or pull request if you have suggestions or encounter any problems.