A command-line tool that generates YAML or tree-style representations of Git repository file structures.
This tool provides functionality similar to the 'tree' command on Linux or the Get-Tree cmdlet on Windows, but specifically designed for Git repositories. It generates either YAML or compact text representations of a Git repository's directory structure using GitPython and nutree.
The tool can include staged files, working directory files, and untracked files, with options to exclude specific patterns and filter by directories.
- Generate YAML or tree-style representations of Git repositories
- Filter files by Git status (staged, working directory, untracked)
- Exclude files using patterns
- Specify output to file or stdout
- Support for directory-specific filtering
Requires Python 3.12 or higher.
# Using uv (recommended)
uv pip install git-tree-project-structure-to-yaml
# Using pip
pip install git-tree-project-structure-to-yamlBasic usage:
# Generate YAML to stdout
git-tree-project-structure-to-yaml /path/to/repo
# Generate YAML to file
git-tree-project-structure-to-yaml /path/to/repo --output structure.yaml
# Generate tree output
git-tree-project-structure-to-yaml /path/to/repo --format tree --output structure.txt
# Exclude specific patterns
git-tree-project-structure-to-yaml /path/to/repo --exclude node_modules --exclude .venvrepo_paths: Paths to directories in the Git repository (positional arguments)--repo: Path to the Git repository root (defaults to current directory)-o, --output: Output file (default: print to stdout)-v, --verbose: Enable verbose output
-f, --format [yaml|tree]: Output format (default: yaml)
--others: Show untracked files in the output (default: True)--stage: Show staged files in the output (default: True)--cached: Show cached/tracked files in the output (default: False)--exclude-standard: Use standard Git exclusions (default: True)--repo-as-root: Use the repository root as the root directory (default: True)-x, --exclude: Patterns to exclude (can be used multiple times)
git-tree-project-structure-to-yaml/:
- .github/:
- workflows/:
- build.yaml
- check.yaml
- release.yaml
- test.yaml
- .gitignore
- .markdownlint.json
- .python-version
- .windsurfrules
- LICENSE
- README.md
# ... and so ongit-tree-project-structure-to-yaml/
├── .github/
│ └── workflows/
│ ├── build.yaml
│ ├── check.yaml
│ ├── release.yaml
│ └── test.yaml
├── .gitignore
├── .markdownlint.json
├── .python-version
├── .windsurfrules
├── LICENSE
├── README.md
# ... and so on
# Clone the repository
git clone https://github.com/Jamie-BitFlight/git-tree-project-structure-to-yaml.git
cd git-tree-project-structure-to-yaml
# Install development dependencies
uv pip install -e ".[dev]"uv run pytestThis project uses:
- Ruff for linting and formatting
- MyPy for type checking
- Pytest for testing
# Format code
uv run ruff format .
# Lint code
uv run ruff check .
# Type check
uv run mypy .git-tree-project-structure-to-yaml/
├── .github/workflows/ # CI/CD configuration
├── scripts/ # Utility scripts
├── src/ # Source code
│ └── git_tree_project_structure_to_yaml/
│ ├── __init__.py
│ └── _cli.py # Main CLI implementation
├── tests/ # Test suite
│ ├── cli/
│ │ └── test_yaml_tree.py
│ └── structure.yaml
├── pyproject.toml # Project configuration
└── README.md # This file
See the LICENSE file for details.
Contributions are welcome! Please feel free to submit a Pull Request.