Skip to main content

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

  1. Clone the repository:
git clone https://github.com/xpos587/git2md.git
cd git2md
  1. 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

  1. Generate markdown for entire repository:
git2md /path/to/repo -o output.md
  1. Include only specific files/directories:
git2md /path/to/repo -inc "src/*.py" "docs/*" -o output.md
  1. Ignore specific patterns:
git2md /path/to/repo -exc "*.pyc" "__pycache__" -o output.md
  1. Copy output to clipboard:
git2md /path/to/repo -cp
  1. 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:

  1. Create a virtual environment:
python -m venv .venv
source .venv/bin/activate
  1. Install dependencies:
pip install -r requirements.txt
  1. Install in editable 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 your 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. Open a Pull Request

Authors

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

git2md-1.0.0.tar.gz (6.0 kB view details)

Uploaded Source

Built Distribution

git2md-1.0.0-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

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

Hashes for git2md-1.0.0.tar.gz
Algorithm Hash digest
SHA256 518f2c1f1a3821aeea0d33fc00942ab76d136c0c45d22b0c715e13133b3d3a53
MD5 f909c6728271cec5e09a6c54c3e4aa6c
BLAKE2b-256 1c490e2fa9f932ebc8c71638b884fbaf5b5afab9d3585ba5c6240c512825ff0e

See more details on using hashes here.

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

Hashes for git2md-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 85b01873d95a69059981121583a8d1de6f16507113dbfd6a9709b33572552d55
MD5 d338cd789714a6306c3ad66ec89444bc
BLAKE2b-256 7a17823fed4d32393cc59024ac7f3c348e5fb71ff152f782d0704a865f58ac25

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page