{"id":39730779,"url":"https://github.com/stkzlv/git2one","last_synced_at":"2026-01-18T11:00:55.442Z","repository":{"id":301636545,"uuid":"1009869749","full_name":"stkzlv/git2one","owner":"stkzlv","description":"Concatenate Git repositories into single files for AI analysis, documentation, and code review. Supports multiple formats with smart filtering.","archived":false,"fork":false,"pushed_at":"2025-06-27T22:07:01.000Z","size":11,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-06-27T23:20:03.829Z","etag":null,"topics":["ai","cli-tools","concatenation","git","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/stkzlv.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-06-27T21:29:03.000Z","updated_at":"2025-06-27T22:16:16.000Z","dependencies_parsed_at":"2025-06-27T23:20:17.589Z","dependency_job_id":null,"html_url":"https://github.com/stkzlv/git2one","commit_stats":null,"previous_names":["stkzlv/git2one"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/stkzlv/git2one","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stkzlv%2Fgit2one","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stkzlv%2Fgit2one/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stkzlv%2Fgit2one/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stkzlv%2Fgit2one/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stkzlv","download_url":"https://codeload.github.com/stkzlv/git2one/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stkzlv%2Fgit2one/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28535156,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-18T10:13:46.436Z","status":"ssl_error","status_checked_at":"2026-01-18T10:13:11.045Z","response_time":98,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai","cli-tools","concatenation","git","python"],"created_at":"2026-01-18T11:00:34.332Z","updated_at":"2026-01-18T11:00:55.381Z","avatar_url":"https://github.com/stkzlv.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# git2one\n\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n[![Python 3.7+](https://img.shields.io/badge/python-3.7+-blue.svg)](https://www.python.org/downloads/)\n[![GitHub issues](https://img.shields.io/github/issues/stkzlv/git2one)](https://github.com/stkzlv/git2one/issues)\n[![GitHub stars](https://img.shields.io/github/stars/stkzlv/git2one)](https://github.com/stkzlv/git2one/stargazers)\n\n`git2one` is a Python script that concatenates all text files in a Git repository into a single output file, making it easy to share or analyze the codebase as a single document. It respects `.gitignore` patterns, supports customizable file extensions, and allows including or excluding specific files or directories. This tool is particularly useful for preparing codebases for AI model input, documentation, or analysis.\n\n## Table of Contents\n\n- [Features](#features)\n- [Installation](#installation)\n- [Usage](#usage)\n  - [Command-Line Options](#command-line-options)\n  - [Examples](#examples)\n- [Configuration](#configuration)\n- [Output Formats](#output-formats)\n- [Testing](#testing)\n- [Troubleshooting](#troubleshooting)\n- [Contributing](#contributing)\n- [License](#license)\n\n## Features\n\n### Core Functionality\n- **Smart File Concatenation**: Combines text files into a single output with clear file separators\n- **Gitignore Respect**: Automatically excludes files and directories specified in `.gitignore`\n- **Multiple Output Formats**: Supports text, JSON, XML, and Markdown formats\n- **Flexible Filtering**: Include/exclude files using glob patterns\n- **Comment Stripping**: Optional removal of Python comments and docstrings\n\n### AI/LLM Integration\n- **Token Estimation**: Estimates token count for AI model compatibility (GPT, Claude, Gemini)\n- **Optimized for AI**: Perfect for preparing codebases for AI analysis and code review\n- **Multiple Formats**: JSON and XML formats for programmatic processing\n\n### Developer-Friendly\n- **Cross-Platform**: Works on Windows, macOS, and Linux\n- **Configurable**: Customizable file extensions and exclusion patterns\n- **Safe Processing**: Automatically skips binary files and handles encoding errors\n\n## Use Cases\n\n- **🤖 AI Code Analysis**: Prepare entire codebases for AI models (ChatGPT, Claude, etc.)\n- **📚 Documentation**: Generate comprehensive code documentation\n- **🔍 Code Review**: Create single-file snapshots for easier review\n- **📊 Analysis**: Feed code into analysis tools that expect single files\n- **📤 Sharing**: Share entire projects as single, readable documents\n- **🏗️ Architecture Review**: Get a bird's-eye view of project structure\n\n## Quick Start\n\n```bash\n# Clone the repository\ngit clone https://github.com/stkzlv/git2one.git\ncd git2one\n\n# Install dependencies\npip install -r requirements.txt\n\n# Run on any Git repository\npython git2one.py /path/to/your/repository\n```\n\n## Requirements\n\n- Python 3.7 or higher\n- Git repository (the tool works with any Git repository)\n\n## Installation\n\n### Method 1: Clone from GitHub (Recommended)\n\n1. Clone the repository:\n   ```bash\n   git clone https://github.com/stkzlv/git2one.git\n   cd git2one\n   ```\n\n2. Install dependencies:\n   ```bash\n   pip install -r requirements.txt\n   ```\n\n### Method 2: Manual Installation\n\n1. Download the script files\n2. Install dependencies manually:\n   ```bash\n   pip install gitignore-parser pyyaml\n   ```\n\n3. Ensure `config.yaml` is in the same directory as `git2one.py` (see [Configuration](#configuration)).\n\n## Usage\nRun the script with the path to the target Git repository:\n\n```bash\npython git2one.py /path/to/repository\n```\n\nThis concatenates all text files into `repo_combined.txt` (default output file).\n\n### Command-Line Options\n- `--output \u003cfile\u003e`: Specify output file (default: `repo_combined.txt`).\n- `--config \u003cfile\u003e`: Path to config file (default: `config.yaml`).\n- `--include \u003cpattern\u003e`: Include only files matching these patterns (e.g., `*.py`, `src/*`).\n- `--exclude \u003cpattern\u003e`: Exclude files matching these patterns (e.g., `poetry.lock`, `tests/`).\n- `--ignore-gitignore`: Ignore `.gitignore` file.\n- `--strip-comments`: Strip Python-style comments (`#`) and docstrings (`\"\"\"...\"\"\"`).\n- `--format \u003cformat\u003e`: Output format (`text`, `json`, `xml`, `markdown`). Auto-detected from file extension if not specified.\n\n### Examples\n1. Concatenate all text files in a repository:\n   ```bash\n   python git2one.py ~/github.com/ProjectA/\n   ```\n   Output: `repo_combined.txt` with files like `README.md`, `src/*.py`, `config/*.yaml`.\n\n2. Include only Python and Markdown files:\n   ```bash\n   python git2one.py ~/github.com/ProjectA/ --include \"*.py\" \"*.md\"\n   ```\n\n3. Exclude large files and strip comments:\n   ```bash\n   python git2one.py ~/github.com/ProjectA/ --exclude \"poetry.lock\" --strip-comments\n   ```\n\n4. Use a custom output file and bypass `.gitignore`:\n   ```bash\n   python git2one.py ~/github.com/ProjectA/ --output combined_code.txt --ignore-gitignore\n   ```\n\n5. Process specific directories:\n   ```bash\n   python git2one.py ~/github.com/ProjectA/ --include \"src/*\" \"config/*\"\n   ```\n\n6. Generate JSON output for programmatic processing:\n   ```bash\n   python git2one.py ~/github.com/ProjectA/ --output combined.json --format json\n   ```\n\n7. Create a Markdown report with syntax highlighting:\n   ```bash\n   python git2one.py ~/github.com/ProjectA/ --output report.md --format markdown\n   ```\n\n8. Export as XML for structured data processing:\n   ```bash\n   python git2one.py ~/github.com/ProjectA/ --output data.xml --format xml\n   ```\n\n## Configuration\nThe `config.yaml` file controls which files are considered text and which are excluded by default. Example:\n\n```yaml\ntext_extensions:\n  - .py\n  - .md\n  - .yaml\n  - .toml\n  - .lock\ndefault_exclusions:\n  - \"*.exe\"\n  - \"*.png\"\n  - \".git/*\"\n  - \".mypy_cache/*\"\ndefault_output: repo_combined.txt\ntoken_multiplier: 1.3\n```\n\n- `text_extensions`: File extensions considered text (e.g., `.py`, `.md`).\n- `default_exclusions`: Patterns to always exclude (e.g., `.git/*`, `*.jpg`).\n- `default_output`: Default output file name.\n- `token_multiplier`: Multiplier for estimating AI model token count.\n\n## Output Formats\n\nGit2one supports multiple output formats:\n\n### Text Format (Default)\nThe default text format contains concatenated files, each prefixed with a header:\n\n```\n--- File: path/to/file.py ---\n[content of file.py]\n\n--- File: path/to/another.md ---\n[content of another.md]\n```\n\n### JSON Format\nJSON format provides structured data with metadata:\n\n```json\n{\n  \"files\": [\n    {\n      \"path\": \"path/to/file.py\",\n      \"content\": \"[file content]\",\n      \"size\": 1234,\n      \"lines\": 45\n    }\n  ],\n  \"summary\": {\n    \"total_files\": 1,\n    \"total_size\": 1234\n  }\n}\n```\n\n### XML Format\nXML format for structured data processing:\n\n```xml\n\u003c?xml version=\"1.0\" encoding=\"UTF-8\"?\u003e\n\u003crepository\u003e\n  \u003cfile path=\"path/to/file.py\"\u003e\n    \u003ccontent\u003e\u003c![CDATA[[file content]]]\u003e\u003c/content\u003e\n  \u003c/file\u003e\n\u003c/repository\u003e\n```\n\n### Markdown Format\nMarkdown format with syntax highlighting for documentation:\n\n```markdown\n# Repository Contents\n\nTotal files: 2\n\n## path/to/file.py\n\n```python\n[file content with syntax highlighting]\n```\n\n## path/to/another.md\n\n```markdown\n[file content]\n```\n```\n\nThe script logs included/excluded files and estimates the total token count for AI model compatibility.\n\n## Troubleshooting\n- **No files included**: Check `config.yaml` for correct `text_extensions`. Verify the repository path:\n  ```bash\n  ls /path/to/repository/src/*.py\n  ```\n- **Files in `debug/` or `outputs/` included**: Ensure `.gitignore` excludes these directories. You can test your theory by explicitly excluding them with --exclude \"debug/\".\n- **High token count**: Exclude large files like `poetry.lock`:\n  ```bash\n  python git2one.py /path/to/repository --exclude \"poetry.lock\"\n  ```\n- **`.gitignore` not respected**: Verify `.gitignore` exists in the repository root and contains valid patterns. You can test if it's being ignored by running with --ignore-gitignore.\n\n## Testing\n\nRun the test suite to verify functionality:\n\n```bash\npython -m pytest test_git2one.py -v\n```\n\nOr run tests with unittest:\n\n```bash\npython test_git2one.py\n```\n\nThe test suite covers:\n- Configuration loading\n- File filtering and pattern matching\n- Comment stripping functionality\n- Multiple output formats\n- Repository processing with various options\n\n## License\nMIT License. See `LICENSE` for details.\n\n## Contributing\n\nWe welcome contributions to git2one! This section outlines the process for contributing to this project.\n\n### Getting Started\n\n1. **Fork the repository** on GitHub at [https://github.com/stkzlv/git2one](https://github.com/stkzlv/git2one)\n2. **Clone your fork** locally:\n   ```bash\n   git clone https://github.com/your-username/git2one.git\n   cd git2one\n   ```\n3. **Install dependencies**:\n   ```bash\n   pip install -r requirements.txt\n   ```\n4. **Create a branch** for your feature or bug fix:\n   ```bash\n   git checkout -b feature/your-feature-name\n   ```\n\n### Development Guidelines\n\n#### Code Style\n- Follow [PEP 8](https://pep8.org/) Python style guidelines\n- Use meaningful variable and function names\n- Add docstrings to all functions and classes\n- Keep functions focused and single-purpose\n- Maximum line length: 100 characters\n\n#### Testing\n- **Write tests** for all new functionality\n- **Run existing tests** to ensure nothing breaks:\n  ```bash\n  python test_git2one.py\n  ```\n- Aim for high test coverage of new code\n- Test edge cases and error conditions\n\n#### Documentation\n- Update the README.md if you add new features\n- Add inline comments for complex logic\n- Update configuration examples if needed\n- Include usage examples for new features\n\n### Submitting Changes\n\n1. **Commit your changes** with clear, descriptive messages:\n   ```bash\n   git add .\n   git commit -m \"Add JSON output format support\n   \n   - Implement JSON formatter with file metadata\n   - Add auto-detection of output format from file extension\n   - Update CLI to support --format option\n   - Add comprehensive tests for new functionality\"\n   ```\n\n2. **Push to your fork**:\n   ```bash\n   git push origin feature/your-feature-name\n   ```\n\n3. **Create a Pull Request** on [GitHub](https://github.com/stkzlv/git2one) with:\n   - Clear title describing the change\n   - Detailed description of what was changed and why\n   - Reference any related issues\n   - Screenshots or examples if applicable\n\n### Pull Request Guidelines\n\n- **One feature per PR**: Keep pull requests focused on a single feature or bug fix\n- **Update tests**: Ensure all tests pass and add new tests for your changes\n- **Update documentation**: Include relevant documentation updates\n- **Clean commit history**: Squash commits if necessary to maintain a clean history\n- **Respond to feedback**: Address review comments promptly and professionally\n\n### Reporting Issues\n\nWhen reporting bugs or requesting features:\n\n1. **Search existing issues** first to avoid duplicates\n2. **Use the issue templates** if available\n3. **Provide detailed information**:\n   - Python version\n   - Operating system\n   - Steps to reproduce the issue\n   - Expected vs actual behavior\n   - Sample code or repository (if applicable)\n\n### Code of Conduct\n\n- **Be respectful** and inclusive in all interactions\n- **Provide constructive feedback** in code reviews\n- **Help newcomers** and answer questions when possible\n- **Focus on the code**, not the person\n- **Assume good intentions** from other contributors\n\n### Development Setup\n\nFor more advanced development:\n\n1. **Set up a virtual environment**:\n   ```bash\n   python -m venv venv\n   source venv/bin/activate  # On Windows: venv\\Scripts\\activate\n   pip install -r requirements.txt\n   ```\n\n2. **Run tests with coverage**:\n   ```bash\n   python -m pytest test_git2one.py --cov=git2one --cov-report=html\n   ```\n\n3. **Check code style**:\n   ```bash\n   flake8 git2one.py test_git2one.py\n   ```\n\n### Feature Requests\n\nWe're always interested in new features! Before implementing:\n\n1. **Open an issue** to discuss the feature\n2. **Explain the use case** and why it would be valuable\n3. **Consider backwards compatibility**\n4. **Discuss implementation approach** if complex\n\n### Questions?\n\n- Open an issue with the \"question\" label on [GitHub](https://github.com/stkzlv/git2one/issues)\n- Check existing issues and documentation first\n- Be specific about what you're trying to achieve\n\nThank you for contributing to git2one! 🎉\n\n## Support\n\nIf you find this tool useful, please consider:\n- ⭐ Starring the repository on [GitHub](https://github.com/stkzlv/git2one)\n- 🐛 Reporting bugs or requesting features via [Issues](https://github.com/stkzlv/git2one/issues)\n- 🔀 Contributing improvements via [Pull Requests](https://github.com/stkzlv/git2one/pulls)\n\n## Author\n\nCreated and maintained by [stkzlv](https://github.com/stkzlv).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstkzlv%2Fgit2one","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstkzlv%2Fgit2one","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstkzlv%2Fgit2one/lists"}