git2prompt is a command-line utility that converts a local Git repository into a formatted text representation. This can be useful for sharing code snippets, project structures, or entire repositories in a plain text format, without needing to archive or transmit the actual files.
pip install git2prompt --userTo use git2prompt, simply run the git2prompt script and provide the path to the Git repository you want to convert:
git2prompt /path/to/your/repoThis will output the formatted text representation of the repository to the console.
The output follows this structure: The text represents a Git repository with the following format:
filename: The name of the file, within a repository format: The format of the file contents The repository ends with --END--
Any text after --END-- are instructions related to the repository.
Copy code
Each file in the repository is represented as a block, with the filename, file format, and contents included. The supported file formats are:
- Text files (
.txt) - Markdown files (
.md) - HTML files (
.html) - Python scripts (
.py)
After all file blocks, the output ends with --END--. Any text after this line is considered instructions related to the repository.
git2prompt respects .gitignore files in the repository. Any files or directories listed in these ignore files will be excluded from the output.
Running python -m git2prompt /path/to/your/repo with the provided example repository will output:
```
This project is licensed under the MIT License.