gitree: git-aware project tree printing and zipping for docs and LLMs
Project description
Gitree
A git-aware CLI tool to provide LLM context for coding projects by combining project files into a single file with a number of different formats to choose from.
โจ Features
| Feature | Description |
|---|---|
| ๐ Project Tree Visualization | Generate clean directory trees with customizable depth and formatting |
| ๐๏ธ Smart Zipping | Create project archives that automatically respect .gitignore rules |
| ๐ฏ Flexible Filtering | Control what's shown with custom ignore patterns, depth limits, and item caps |
| ๐ Gitignore Integration | Use .gitignore files at any depth level, or disable entirely when needed |
| ๐ Multiple Output Formats | Export to files, copy to clipboard, or display with emoji icons |
| ๐ Directory-Only View | Show just the folder structure without files for high-level overviews |
| ๐ Project Summary | Display file and folder counts at each directory level with summary mode |
๐ฅ The problems it solves:
- sharing project structure in issues or pull requests
- generating directory trees for documentation
- pasting project layouts into LLMs
- converting entire codebases to a single json file using
.gitignorefor prompting LLMs.
๐ฆ Installation
Run this command in your terminal:
# Install using pip
pip install gitree
๐ก Usage
To use this tool, refer to this format:
gitree [path] [other CLI args/flags]
Open a terminal in any project and run:
# path should default to .
gitree
Example output:
Gitree
โโ gitree/
โ โโ constants/
โ โ โโ __init__.py
โ โ โโ constant.py
โ โโ services/
โ โ โโ __init__.py
โ โ โโ draw_tree.py
โ โ โโ list_enteries.py
โ โ โโ parser.py
โ โ โโ zip_project.py
โ โโ utilities/
โ โ โโ __init__.py
โ โ โโ gitignore.py
โ โ โโ utils.py
โ โโ __init__.py
โ โโ main.py
โโ CODE_OF_CONDUCT.md
โโ CONTRIBUTING.md
โโ LICENSE
โโ pyproject.toml
โโ README.md
โโ requirements.txt
โโ SECURITY.md
Using emojis as file/directory icons:
gitree --emoji
Example output:
Gitree
โโ ๐ gitree/
โ โโ ๐ constants/
โ โ โโ ๐ __init__.py
โ โ โโ ๐ constant.py
โ โโ ๐ services/
โ โ โโ ๐ __init__.py
โ โ โโ ๐ draw_tree.py
โ โ โโ ๐ list_enteries.py
โ โ โโ ๐ parser.py
โ โ โโ ๐ zip_project.py
โ โโ ๐ utilities/
โ โ โโ ๐ __init__.py
โ โ โโ ๐ gitignore.py
โ โ โโ ๐ utils.py
โ โโ ๐ __init__.py
โ โโ ๐ main.py
โโ ๐ CODE_OF_CONDUCT.md
โโ ๐ CONTRIBUTING.md
โโ ๐ LICENSE
โโ ๐ pyproject.toml
โโ ๐ README.md
โโ ๐ requirements.txt
โโ ๐ SECURITY.md
For zipping a directory:
gitree --zip out
creates out.zip in the same directory.
๐งญ Interactive Mode
Gitree supports an interactive mode that allows you to select files and directories step-by-step instead of relying only on CLI flags.
This is useful when:
- you want fine-grained control over included files
- you prefer a guided terminal-based selection flow
- you want to explore a project before exporting its structure
Enable Interactive Mode
Use the -i or --interactive flag:
gitree --interactive
# or
gitree -i
How It Works
When interactive mode is enabled, Gitree will:
- Scan the project directory (respecting
.gitignore) - Present an interactive file and folder selection menu
- Allow you to choose what to include or exclude
- Generate output based on your selections
Interactive Controls
During interactive selection, the following keys are supported:
- โ / โ โ navigate items
- Space โ select / deselect item
- Enter โ confirm selection
- Esc / Ctrl+C โ exit interactive mode
Example
gitree -i --emoji --out context.txt
This will:
- launch interactive selection
- display output using emojis
- save the result to
context.txt
Updating Gitree:
To update the tool, type:
pip install -U gitree
Pip will automatically replace the older version with the latest release.
๐งช Continuous Integration (CI)
Gitree uses Continuous Integration (CI) to ensure code quality and prevent regressions on every change.
What CI Does
- Runs automated checks on every pull request
- Verifies that all CLI arguments work as expected
- Ensures the tool behaves consistently across updates
Current Test Coverage
| Test Type | Description |
|---|---|
| CLI Argument Tests | Validates all supported CLI flags and options |
| Workflow Checks | Ensures PRs follow required checks before merging |
โน๏ธ CI tests are continuously expanding as new features are added.
โ๏ธ CLI Arguments
In addition to the directory path, the following options are available:
| Argument | Description |
|---|---|
--version, -v |
Displays the installed version. |
--max-depth |
Limits recursion depth. Example: --depth 1 shows only top-level files and folders. |
--hidden-items |
Includes hidden files and directories. Does not override .gitignore. |
--exclude |
Patterns of files to exclude. Example: --exclude *.pyc __pycache__. |
--exclude-depth |
Limits depth for --exclude patterns. Example: --exclude-depth 2 applies exclude rules only to first 2 levels. |
--gitignore-depth |
Controls how deeply .gitignore files are discovered. Example: --gitignore-depth 0 uses only the root .gitignore. |
--no-gitignore |
Ignores all .gitignore rules when set. |
--max-items |
Limits items shown per directory. Extra items are summarized as ... and x more items. Default: 20. |
--no-limit |
Removes the per-directory item limit. |
--no-files |
Hide files from the tree (only show directories). |
--emoji, -e |
Show emojis in tree output. |
--summary |
Print a summary of the number of files and folders at each level. |
--zip [name], -z |
Zips the project while respecting .gitignore. Example: --zip a creates a.zip. |
--json [file] |
Export tree as JSON to specified file. Example: --json tree.json. |
--txt [file] |
Export tree as text to specified file. Example: --txt tree.txt. |
--md [file] |
Export tree as Markdown to specified file. Example: --md tree.md. |
--output [file], -o |
Save tree structure to file. Example: --output tree.txt or --output tree.md for markdown format. |
--copy, -c |
Copy tree output to clipboard. |
--include |
Patterns of files to include (used in interactive mode). Example: --include *.py *.js. |
--include-file-type |
Include files of a specific type. Example: --include-file-type json or --include-file-type .py. Case-insensitive. |
--include-file-types |
Include files of multiple types. Example: --include-file-types png jpg json. Case-insensitive. |
--json [file] |
Export tree as JSON to specified file. By default, includes file contents (up to 1MB per file). |
--txt [file] |
Export tree as text to specified file. By default, includes file contents (up to 1MB per file). |
--md [file] |
Export tree as Markdown to specified file. By default, includes file contents with syntax highlighting (up to 1MB per file). |
--no-contents |
Don't include file contents when exporting to JSON, TXT, or MD formats. Only the tree structure will be included. |
--interactive, -i |
Interactive mode: select files to include using a terminal-based UI. |
--include |
Patterns of files to include. Example: --include *.py *.js. |
--init-config |
Create a default config.json file in the current directory. |
--config-user |
Open config.json in the default editor. |
--no-config |
Ignore config.json and use hardcoded defaults. |
๐ File Contents in Exports
When using --json, --txt, or --md flags, file contents are included by default. This feature:
- โ Includes text file contents (up to 1MB per file)
- โ
Detects and marks binary files as
[binary file] - โ
Handles large files by marking them as
[file too large: X.XXmb] - โ Uses syntax highlighting in Markdown format based on file extension
- โ
Works with all filtering options (
--exclude,--include,.gitignore, etc.)
To export only the tree structure without file contents, use the --no-contents flag:
gitree --json output.json --no-contents
Installation (for Contributors)
Clone the repository:
git clone https://github.com/ShahzaibAhmad05/Gitree
Move into the project directory:
cd Gitree
Setup a Virtual Environment (to avoid package conflicts):
python -m venv .venv
Activate the virtual environment:
.venv/Scripts/Activate # on windows
.venv/bin/activate # on linux/macOS
If you get an execution policy error on windows, run this:
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
Install dependencies in the virtual environment:
pip install -r requirements.txt
The tool is now available as a Python CLI in your virtual environment.
For running the tool, type (venv should be activated):
gitree
For running tests after making any changes:
python -m unittest discover tests
Contributions
This is YOUR tool. Issues and pull requests are welcome.
Gitree is kept intentionally small and readable, so contributions that preserve simplicity are especially appreciated.
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 gitree-0.2.2.tar.gz.
File metadata
- Download URL: gitree-0.2.2.tar.gz
- Upload date:
- Size: 27.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f15a8408cb14e6e5723f94fee3c58fca0df00c6b19501b3082b6146a4d7a82c3
|
|
| MD5 |
49d118568b1879e401ab681a0a81bb53
|
|
| BLAKE2b-256 |
7910a61db6d0d66c6e230e0ccc8d68eb4225413c14fe4a883754e5789fa436ed
|
Provenance
The following attestation bundles were made for gitree-0.2.2.tar.gz:
Publisher:
workflow.yml on ShahzaibAhmad05/gitree
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
gitree-0.2.2.tar.gz -
Subject digest:
f15a8408cb14e6e5723f94fee3c58fca0df00c6b19501b3082b6146a4d7a82c3 - Sigstore transparency entry: 780506687
- Sigstore integration time:
-
Permalink:
ShahzaibAhmad05/gitree@9e7018729d6282e21a68b575cf8c3e43a61ceefc -
Branch / Tag:
refs/tags/v0.2.2 - Owner: https://github.com/ShahzaibAhmad05
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
workflow.yml@9e7018729d6282e21a68b575cf8c3e43a61ceefc -
Trigger Event:
release
-
Statement type:
File details
Details for the file gitree-0.2.2-py3-none-any.whl.
File metadata
- Download URL: gitree-0.2.2-py3-none-any.whl
- Upload date:
- Size: 30.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
806a400aca8434b1504fe9677275781946d49f04d39e792e4652694c627a0135
|
|
| MD5 |
303df3891196b8f5472f9131c08607d1
|
|
| BLAKE2b-256 |
a992f892b136f6add22eb91e0a9dfa740c561d6770eca1e001f300094e3b2c2c
|
Provenance
The following attestation bundles were made for gitree-0.2.2-py3-none-any.whl:
Publisher:
workflow.yml on ShahzaibAhmad05/gitree
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
gitree-0.2.2-py3-none-any.whl -
Subject digest:
806a400aca8434b1504fe9677275781946d49f04d39e792e4652694c627a0135 - Sigstore transparency entry: 780506690
- Sigstore integration time:
-
Permalink:
ShahzaibAhmad05/gitree@9e7018729d6282e21a68b575cf8c3e43a61ceefc -
Branch / Tag:
refs/tags/v0.2.2 - Owner: https://github.com/ShahzaibAhmad05
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
workflow.yml@9e7018729d6282e21a68b575cf8c3e43a61ceefc -
Trigger Event:
release
-
Statement type: