Convert Git repository contents to Markdown format
Project description
๐ git2md
๐ 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
โจ Features
- ๐ณ Repository Directory Tree Generation: outputs repository structure in
treeblock format. - ๐ File to Markdown Conversion:
- Supports syntax highlighting for code files.
Converts Jupyter Notebook (.ipynb) and PDF (.pdf) to Markdown.
- ๐ฏ Support for
.gitignore,.globalignoreand.mdignorefor local projects:- Automatically excludes files/directories specified in
.gitignore,.globalignoreor.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.
๐ฌ Demonstration
Below is a demonstration of how git2md works:
๐ Requirements
- ๐ Python 3.9 or newer
- ๐ง
Linux Operating SystemNow supports Windows, MacOS, Linux (X11 and Wayland) - ๐ฆ Dependencies:
pathspec(for.gitignore,.mdignore,.globalignoresupport)(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)
๐ฅ Installation
๐ฆ Install via PyPI
You can install git2md directly through PyPI using pip:
pip install git2md
๐๏ธ Install via AUR (Arch Linux)
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
๐จ Install from Source
-
Clone the repository:
git clone https://github.com/xpos587/git2md.git cd git2md
-
Build and install:
python setup.py build pip install .
๐ Usage
๐ป Basic Command
git2md [path] [options]
If path is not specified, the current directory will be used.
โ๏ธ Options
| 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 |
๐ Examples
๐ Generate Markdown for Entire Repository
git2md /path/to/repo -o output.md
๐ Exclude Specific Files Using Patterns
git2md --ignore "./assets/style-*.css" "*.log" "*.tmp" -o output.md
๐๏ธ Copy Result to Clipboard
git2md --copy
๐ Output Format
๐ณ Directory Tree
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
๐ File Contents
Each file is included with its relative path in the header, followed by its contents in a code block.
๐ Example for Python File (main.py)
# File: src/main.py
```
print("Hello, world!")
```
# End of file: src/main.py
๐ Example for Jupyter Notebook (notebook.ipynb)
Content is converted from .ipynb to Markdown and included directly:
# File: notebook.ipynb
# Converted content from Jupyter Notebook...
# End of file: notebook.ipynb
๐ Example for PDF (document.pdf)
Text is extracted in Markdown format:
# File: document.pdf
# Extracted content from PDF...
# End of file: document.pdf
๐ง Global Exclusion Patterns
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.
๐ Example .mdignore
__pycache__/
*.pyc
.mypy_cache/
.env
*.log
๐จโ๐ป Development
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 .
๐ License
This project is licensed under the MIT License. See the LICENSE file for details.
๐ค Contributing
- 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.
๐ฅ Authors
Michael (x30827pos@gmail.com)
๐ Acknowledgments
Thanks to the developers of repomix and git2txt.
The idea emerged from the need for universal and simplified repository documentation for LLM-based workflows.
Project details
Release history Release notifications | RSS feed
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file git2md-1.1.5.tar.gz.
File metadata
- Download URL: git2md-1.1.5.tar.gz
- Upload date:
- Size: 13.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cc1571576fa8fab5645667ef861c0b2f8328f5235f0cab503c3594be92306367
|
|
| MD5 |
581ade40ec91b5f167d560665a39a061
|
|
| BLAKE2b-256 |
bebb50f2a3fdfca9a7189fac04339f9c3198fbaa1ceb6464c82ce04e246e87cb
|
Provenance
The following attestation bundles were made for git2md-1.1.5.tar.gz:
Publisher:
release.yaml on Xpos587/git2md
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
git2md-1.1.5.tar.gz -
Subject digest:
cc1571576fa8fab5645667ef861c0b2f8328f5235f0cab503c3594be92306367 - Sigstore transparency entry: 170697162
- Sigstore integration time:
-
Permalink:
Xpos587/git2md@352a150cb5973b1429df19aced0a14aeb0887531 -
Branch / Tag:
refs/tags/1.1.5 - Owner: https://github.com/Xpos587
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yaml@352a150cb5973b1429df19aced0a14aeb0887531 -
Trigger Event:
push
-
Statement type:
File details
Details for the file git2md-1.1.5-py3-none-any.whl.
File metadata
- Download URL: git2md-1.1.5-py3-none-any.whl
- Upload date:
- Size: 13.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8848589e443589087bb62e95e8b0af96de3194778f54a82f7a680a8327deb046
|
|
| MD5 |
92677e37f477e5ceec79906be20e319d
|
|
| BLAKE2b-256 |
78f53ccd8da2bd25d88ad02fed32aa14b6cd7c45c9acc0c306709019217a88ad
|
Provenance
The following attestation bundles were made for git2md-1.1.5-py3-none-any.whl:
Publisher:
release.yaml on Xpos587/git2md
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
git2md-1.1.5-py3-none-any.whl -
Subject digest:
8848589e443589087bb62e95e8b0af96de3194778f54a82f7a680a8327deb046 - Sigstore transparency entry: 170697164
- Sigstore integration time:
-
Permalink:
Xpos587/git2md@352a150cb5973b1429df19aced0a14aeb0887531 -
Branch / Tag:
refs/tags/1.1.5 - Owner: https://github.com/Xpos587
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yaml@352a150cb5973b1429df19aced0a14aeb0887531 -
Trigger Event:
push
-
Statement type: