Convert git repository contents to markdown format
Project description
git2md
A command-line tool for converting Git repository contents to Markdown format. This tool helps you create documentation by generating a Markdown file containing the repository structure and the contents of all files.
Features
- Generate repository file structure tree
- Convert files to Markdown with proper syntax highlighting
- Support for .gitignore patterns
- Custom file/directory ignore patterns
- Include specific files/directories only
- Copy output to clipboard (requires wl-copy)
- Skip empty files
- Supports custom global ignore patterns via .globalignore
Requirements
- Python 3.12 or higher
- Linux operating system
- wl-copy (for clipboard functionality)
- pathspec>=0.12.1 (for .gitignore support)
Installation
- Clone the repository:
git clone https://github.com/xpos587/git2md.git
cd git2md
- Run the installation script:
python install.py
The script will:
- Install the package in your Python environment
- Create a symlink in /usr/local/bin for global access (requires sudo)
Usage
Basic usage:
git2md <path> [options]
Options:
positional arguments:
path Path to the git project directory.
optional arguments:
-h, --help Show this help message and exit
-o, --output Output file path
-exc, --exclude List of files/directories to ignore (glob patterns)
-inc, --include List of files/directories to include (glob patterns)
-se, --skip-empty Skip empty files
-cp, --clipboard Copy output to clipboard
-igi, --ignoregitignore Ignore .gitignore and .globalignore files
Examples
- Generate markdown for entire repository:
git2md /path/to/repo -o output.md
- Include only specific files/directories:
git2md /path/to/repo -inc "src/*.py" "docs/*" -o output.md
- Ignore specific patterns:
git2md /path/to/repo -exc "*.pyc" "__pycache__" -o output.md
- Copy output to clipboard:
git2md /path/to/repo -cp
- Ignore .gitignore rules:
git2md -igi -o output.md /path/to/repo
Global Ignore Patterns
You can create a .globalignore
file in the same directory as the script to specify patterns that should be ignored across all repositories. The format is the same as .gitignore
.
Example .globalignore
:
__pycache__/
*.pyc
.git/
.env
.venv
Development
To set up the development environment:
- Create a virtual environment:
python -m venv .venv
source .venv/bin/activate
- Install dependencies:
pip install -r requirements.txt
- Install in editable mode:
pip install -e .
License
This project is licensed under the MIT License - see the LICENSE file for details.
Contributing
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
Authors
- Michael (x30827pos@gmail.com)
Acknowledgments
- Thanks to the pathspec library for .gitignore support
- Inspired by the need to easily document Git repositories for LLM
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file git2md-1.0.0.tar.gz
.
File metadata
- Download URL: git2md-1.0.0.tar.gz
- Upload date:
- Size: 6.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 518f2c1f1a3821aeea0d33fc00942ab76d136c0c45d22b0c715e13133b3d3a53 |
|
MD5 | f909c6728271cec5e09a6c54c3e4aa6c |
|
BLAKE2b-256 | 1c490e2fa9f932ebc8c71638b884fbaf5b5afab9d3585ba5c6240c512825ff0e |
File details
Details for the file git2md-1.0.0-py3-none-any.whl
.
File metadata
- Download URL: git2md-1.0.0-py3-none-any.whl
- Upload date:
- Size: 6.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 85b01873d95a69059981121583a8d1de6f16507113dbfd6a9709b33572552d55 |
|
MD5 | d338cd789714a6306c3ad66ec89444bc |
|
BLAKE2b-256 | 7a17823fed4d32393cc59024ac7f3c348e5fb71ff152f782d0704a865f58ac25 |