Skip to content

A tool to clone GitHub repositories, document their directory structure, and extract file contents into a text file.

License

Notifications You must be signed in to change notification settings

blaisewf/repo2txt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

repo2txt

repo2txt is a Python package that clones a GitHub repository, generates a text file containing the repository's directory structure and the contents of all its files, and handles cleanup.

Installation

You can install repo2txt using pip:

pip install git+https://github.com/blaisewf/repo2txt.git

Alternatively, you can clone the repository and install it locally:

git clone https://github.com/blaisewf/repo2txt.git
cd repo2txt
pip install .

Usage

Once installed, you can use the CLI command repo2txt to process a GitHub repository. Here’s the basic syntax:

repo2txt --repo-url <repository_url> --output-file <output_file_path> --branch <branch_name> --config <config_file_path> --local-path <local_path>

Example

From GitHub:

repo2txt --repo-url https://github.com/example/repository.git --output-file output.txt --branch develop --config repo2txt/configs/config.json

Using a local folder:

repo2txt --local-path downloads/my-project --output-file output.txt  --config repo2txt/configs/config.json

This command will:

  1. Clone the repository from https://github.com/example/repository.git.
  2. Generate a text file output.txt containing the directory structure and contents of all files in the repository.
  3. Clean up the cloned repository directory.

Configuration

In the config file you can specify which files you want to ignore when generating the text file. The config file should be a JSON file with the following structure:

{
  "ignore": ["*.md", "*.log", "node_modules", ".git"]
}

License

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

References

About

A tool to clone GitHub repositories, document their directory structure, and extract file contents into a text file.

Topics

Resources

License

Stars

Watchers

Forks

Languages