π A powerful command-line tool for converting Git repository contents into Markdown format. This tool is perfect for developers and documentation specialists who need to create structured Markdown files based on repository contents, including directory trees and file contents.
Read README in Russian here
- π³ Repository Directory Tree Generation: outputs repository structure in
tree
block format. - π File to Markdown Conversion:
- Supports syntax highlighting for code files.
Converts Jupyter Notebook (.ipynb
) and PDF (.pdf
) to Markdown.
- π― Support for
.gitignore
,.globalignore
and.mdignore
for local projects:- Automatically excludes files/directories specified in
.gitignore
,.globalignore
or.mdignore
.
- Automatically excludes files/directories specified in
- π Custom Exclusion Patterns: use regular expressions to exclude specific files or directories.
- ποΈ Skip Empty Files: ignores files without content.
- π Copy Results to Clipboard: simplifies using generated Markdown.
Below is a demonstration of how git2md
works:
- π Python 3.9 or newer
- π§
Linux Operating SystemNow supports Windows, MacOS, Linux (X11 and Wayland) - π¦ Dependencies:
pathspec
(for.gitignore
,.mdignore
,.globalignore
support)(support temporarily limited)nbconvert
(for Jupyter Notebook conversion)(support discontinued, will be replaced with better alternatives)PyMuPDF4LLM
(for PDF conversion)wl-copy/xsel/xclip
(optional, Linux-only for clipboard functionality)
You can install git2md
directly through PyPI using pip:
pip install git2md
For Arch Linux users, the package is available in AUR as python-git2md. It can be installed using AUR helpers like paru
or yay
:
paru -S python-git2md
-
Clone the repository:
git clone https://github.com/xpos587/git2md.git cd git2md
-
Build and install:
python setup.py build pip install .
git2md [path] [options]
If path is not specified, the current directory will be used.
Option | Description |
---|---|
path |
Path to project directory or Git file (default: current folder) |
-o , --output |
Path to save generated Markdown |
-c , --copy |
Copy result to clipboard |
--ignore |
List of patterns to exclude files or directories |
git2md /path/to/repo -o output.md
git2md --ignore "./assets/style-*.css" "*.log" "*.tmp" -o output.md
git2md --copy
The directory tree is included as a code block with language identifier tree
. For example:
src/
βββ main.py
βββ utils/
β βββ helper.py
β βββ __init__.py
βββ README.md
Each file is included with its relative path in the header, followed by its contents in a code block.
# File: src/main.py
```
print("Hello, world!")
```
# End of file: src/main.py
Content is converted from .ipynb
to Markdown and included directly:
# File: notebook.ipynb
# Converted content from Jupyter Notebook...
# End of file: notebook.ipynb
Text is extracted in Markdown format:
# File: document.pdf
# Extracted content from PDF...
# End of file: document.pdf
You can create a .mdignore
file in the same directory as the script to specify patterns that should be excluded for all repositories. The format is identical to .gitignore
.
__pycache__/
*.pyc
.mypy_cache/
.env
*.log
To set up the development environment:
-
Create a virtual environment:
micromamba create -p ./.micromamba/ -f environment.yml micromamba activate -p ./.micromamba/
-
Install the project in development mode:
pip install -e .
This project is licensed under the MIT License. See the LICENSE file for details.
- Fork the repository.
- Create a 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
). - Create a Pull Request.
Michael ([email protected])
Thanks to the developers of repomix and git2txt.
The idea emerged from the need for universal and simplified repository documentation for LLM-based workflows.