Skip to main content

🔄 git2md

PyPI Python Version Build Status License AUR version

🚀 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 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.
  • 🔍 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:

Demo of git2md


📋 Requirements

  • 🐍 Python 3.9 or newer
  • 🐧 Linux Operating System Now supports Windows, MacOS, Linux (X11 and Wayland)
  • 📦 Dependencies:
    • pathspec (for .gitignore, .mdignore, .globalignore support)
    • nbconvert (for Jupyter Notebook conversion) (support temporarily limited)
    • PyMuPDF4LLM (for PDF conversion) (support discontinued, will be replaced with better alternatives)
    • 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

  1. Clone the repository:

    git clone https://github.com/xpos587/git2md.git
    cd git2md
    
  2. 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:

  1. Create a virtual environment:

    micromamba create -p ./.micromamba/ -f environment.yml
    micromamba activate -p ./.micromamba/
    
  2. 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

  1. Fork the repository.
  2. Create a feature branch (git checkout -b feature/amazing-feature).
  3. Commit your changes (git commit -m 'Add some amazing feature').
  4. Push to the branch (git push origin feature/amazing-feature).
  5. 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.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

git2md-1.1.7.tar.gz (13.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

git2md-1.1.7-py3-none-any.whl (13.6 kB view details)

Uploaded Python 3

File details

Details for the file git2md-1.1.7.tar.gz.

File metadata

  • Download URL: git2md-1.1.7.tar.gz
  • Upload date:
  • Size: 13.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for git2md-1.1.7.tar.gz
Algorithm Hash digest
SHA256 907df69c446e0e747d6530fd8ec1d882835c2d56daf1eeffbb2032fb7b3d2d9d
MD5 44c3d1ecea23383055dcbfe2acc89f0f
BLAKE2b-256 5caaf0fd0fdfb48b8543ae60f612defc13ab85e9cdadd23dc9851b892d9b2193

See more details on using hashes here.

Provenance

The following attestation bundles were made for git2md-1.1.7.tar.gz:

Publisher: release.yaml on Xpos587/git2md

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file git2md-1.1.7-py3-none-any.whl.

File metadata

  • Download URL: git2md-1.1.7-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

Hashes for git2md-1.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 f99d9d6216824d408a8b3a2f0263ee7f0be501a7954c6e27e8eb3e4fed47a8af
MD5 46ac2e021ad785a15e1635d6cf9d388c
BLAKE2b-256 05f8a8fcbb1b06cc5bb6ef5fe53e9b882e0e7598ef932235e6f15f46ff1bb001

See more details on using hashes here.

Provenance

The following attestation bundles were made for git2md-1.1.7-py3-none-any.whl:

Publisher: release.yaml on Xpos587/git2md

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

1.1.7 This release

2 files

1.1.6

2 files

1.1.5

2 files

1.1.4

2 files

1.1.3

2 files

1.1.2

2 files

1.1.1

2 files

1.1.0

2 files

1.0.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page