{"id":22931007,"url":"https://github.com/hyperb1iss/git-surgeon","last_synced_at":"2025-06-30T00:06:48.903Z","repository":{"id":264771414,"uuid":"894352252","full_name":"hyperb1iss/git-surgeon","owner":"hyperb1iss","description":"Perform surgical operations easily on Git repositories. Easily truncate history, remove files, and update author info with simple commands.","archived":false,"fork":false,"pushed_at":"2024-11-30T02:15:45.000Z","size":79,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-26T17:11:18.035Z","etag":null,"topics":["filter-branch","filter-repo","git","history","python","rewrite","surgeon"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hyperb1iss.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","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},"funding":{"github":"hyperb1iss","ko_fi":"hyperb1iss"}},"created_at":"2024-11-26T07:55:32.000Z","updated_at":"2025-05-25T04:19:57.000Z","dependencies_parsed_at":null,"dependency_job_id":"85c02da8-d695-419c-86ea-678cb3b31e46","html_url":"https://github.com/hyperb1iss/git-surgeon","commit_stats":null,"previous_names":["hyperb1iss/git-surgeon"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/hyperb1iss/git-surgeon","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyperb1iss%2Fgit-surgeon","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyperb1iss%2Fgit-surgeon/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyperb1iss%2Fgit-surgeon/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyperb1iss%2Fgit-surgeon/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hyperb1iss","download_url":"https://codeload.github.com/hyperb1iss/git-surgeon/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyperb1iss%2Fgit-surgeon/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262685693,"owners_count":23348451,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["filter-branch","filter-repo","git","history","python","rewrite","surgeon"],"created_at":"2024-12-14T10:33:42.162Z","updated_at":"2025-06-30T00:06:48.891Z","avatar_url":"https://github.com/hyperb1iss.png","language":"Python","funding_links":["https://github.com/sponsors/hyperb1iss","https://ko-fi.com/hyperb1iss","https://ko-fi.com/hyperb1iss)!"],"categories":[],"sub_categories":[],"readme":"# 🔪 Git Surgeon\n\n\u003e _Because some git operations require surgical precision_\n\n[![Build Status](https://img.shields.io/github/actions/workflow/status/hyperb1iss/git-surgeon/cicd.yml?branch=main\u0026logo=github\u0026logoColor=white)](https://github.com/hyperb1iss/git-surgeon/actions/workflows/cicd.yml)\n[![PyPI version](https://img.shields.io/pypi/v/git-surgeon.svg?logo=python\u0026logoColor=white)](https://pypi.org/project/git-surgeon/)\n[![Python Versions](https://img.shields.io/pypi/pyversions/git-surgeon?logo=python\u0026logoColor=white)](https://pypi.org/project/git-surgeon/)\n[![License](https://img.shields.io/badge/license-GPLv2-blue.svg?logo=gnu)](LICENSE)\n[![Code style: ruff](https://img.shields.io/badge/code%20style-ruff-000000.svg?logo=ruff)](https://github.com/astral-sh/ruff)\n[![Type Checking: mypy](https://img.shields.io/badge/type%20checking-mypy-blue?logo=python)](https://github.com/python/mypy)\n\nGit Surgeon is a powerful command-line tool for safely performing complex and potentially destructive operations on git repositories. Think of it as a precise scalpel for your git history! 🔪\n\n## ✨ Features\n\n- 🧹 **File Purging**: Remove sensitive files or patterns from entire git history\n- ✂️ **History Truncation**: Safely truncate repository history while preserving state\n- 🧰 **Repository Cleanup**: Remove large files and sensitive data\n- 👥 **Author Rewriting**: Update author and committer information across history\n- 🔒 **Safety First**: Automatic backups and dry-run capabilities\n- 🎯 **Precise Control**: Fine-grained control over operations\n\n## 🚀 Installation\n\nGit Surgeon requires Python 3.10 or higher and depends on the git-filter-repo tool for some operations. You can install it using either pip or Poetry.\n\n### Using pip\n\nFor most users, installing via pip is the recommended method:\n\n```bash\npip install git-surgeon\n```\n\n### Using Poetry (Development)\n\nFor developers who want to contribute or modify the code, Poetry provides better dependency management and isolation:\n\n```bash\ngit clone https://github.com/hyperb1iss/git-surgeon\ncd git-surgeon\npoetry install\n```\n\n## 🎯 Quick Start\n\nGit Surgeon provides several core operations for managing your repository's history. Here are some common use cases:\n\n```bash\n# Remove all .env files from history\ngit-surgeon remove \"**/.env\" --backup\n\n# Truncate history to keep only recent commits\ngit-surgeon truncate --keep-recent 100\n\n# Clean up large files\ngit-surgeon clean --size-threshold 50MB\n```\n\n## 🔧 Commands\n\n### File Operations\n\n#### Remove Files\n\nThe remove command helps you permanently delete files from your repository's history. This is particularly useful for removing sensitive data that was accidentally committed:\n\n```bash\n# Remove specific files from history\ngit-surgeon remove \"path/to/file\" --backup\n\n# Remove using glob patterns\ngit-surgeon remove \"**/*.log\" --preserve-recent\n\n# Remove from specific branches\ngit-surgeon remove \"secrets.json\" --branches main,develop\n```\n\n#### History Truncation\n\nThe truncate command allows you to manage your repository's history by keeping only the commits you need. This can help reduce repository size and simplify history:\n\n```bash\n# Keep only recent history\ngit-surgeon truncate --keep-recent 50\n\n# Truncate before a date\ngit-surgeon truncate --before \"2023-01-01\"\n\n# Truncate after a specific commit\ngit-surgeon truncate --after abc123\n```\n\n#### Repository Cleanup\n\nThe cleanup command helps you maintain a healthy repository by removing large files and cleaning up sensitive data:\n\n```bash\n# Remove large files\ngit-surgeon clean --size-threshold 50MB\n\n# Clean sensitive data\ngit-surgeon clean --sensitive-data\n\n# Cleanup with custom patterns\ngit-surgeon clean --patterns \"**/*.zip,**/*.jar\"\n```\n\n#### Author Rewriting\n\nThe author rewriting feature uses git-filter-repo to safely update author and committer information across your repository's history:\n\n```bash\n# Rewrite a single author\ngit-surgeon rewrite-authors --old \"Old Name \u003cold@email.com\u003e\" --new \"New Name \u003cnew@email.com\u003e\"\n\n# Rewrite multiple authors using a mapping file\ngit-surgeon rewrite-authors --mapping-file authors.json\n\n# Update both author and committer information\ngit-surgeon rewrite-authors --mapping-file authors.json --update-committer\n\n# Example authors.json format:\n[\n  {\n    \"old\": \"Old Name \u003cold@email.com\u003e\",\n    \"new\": \"New Name \u003cnew@email.com\u003e\"\n  },\n  {\n    \"old\": \"Another Old \u003canother@old.com\u003e\",\n    \"new\": \"Another New \u003canother@new.com\u003e\"\n  }\n]\n```\n\n## 🛡️ Safety Features\n\nGit Surgeon prioritizes the safety of your repository by implementing several protective measures:\n\n### Automatic Backups\n\nBefore performing any destructive operation, Git Surgeon automatically creates a timestamped backup of your repository:\n\n```bash\n# Operations create timestamped backups\nmy_repo_backup_20240125_120130/\n```\n\n### Dry Run Mode\n\nAll operations support a dry-run mode that shows you exactly what would happen without making any changes:\n\n```bash\n# See what would be removed\ngit-surgeon remove \"*.log\" --dry-run\n\n# Preview truncation impact\ngit-surgeon truncate --before 2023-01-01 --dry-run\n```\n\n### State Validation\n\nBefore performing any operation, Git Surgeon performs comprehensive safety checks:\n\n- Verifies repository state\n- Checks for uncommitted changes\n- Validates branch states\n- Ensures backup creation\n- Validates the integrity of the git repository\n- Detects detached HEAD state\n- Checks for untracked files\n\n## 🎯 Use Cases\n\n### Removing Sensitive Data\n\nWhen sensitive data like API keys or credentials accidentally make it into your repository, Git Surgeon can help remove them completely:\n\n```bash\n# Remove all .env files\ngit-surgeon remove \"**/.env\"\n\n# Clean up API keys and tokens\ngit-surgeon clean --sensitive-data\n```\n\n### Repository Maintenance\n\nKeep your repository clean and efficient by removing unnecessary files and optimizing history:\n\n```bash\n# Remove old logs and temp files\ngit-surgeon remove \"**/*.log,**/*.tmp\"\n\n# Clean up large build artifacts\ngit-surgeon clean --size-threshold 100MB\n```\n\n### History Management\n\nManage your repository's history to keep it focused and relevant:\n\n```bash\n# Keep only recent history\ngit-surgeon truncate --keep-recent 100\n\n# Remove history before specific date\ngit-surgeon truncate --before \"2023-01-01\"\n```\n\n## 🔧 Configuration\n\nGit Surgeon can be configured through command-line options or configuration files:\n\n### Command Line Options\n\n```bash\n# General options\n--backup           Create backup before operation\n--dry-run         Show what would be done\n--force           Skip confirmation prompts\n\n# Pattern options\n--preserve-recent  Keep files in most recent commit\n--branches        Specify branches to process\n```\n\n## 🤝 Contributing\n\nYes please! Contributions are welcome:\n\n1. Fork the repository\n2. Create your feature branch (`git checkout -b feature/AmazingFeature`)\n3. Commit your changes (`git commit -m 'Add some AmazingFeature'`)\n4. Push to the branch (`git push origin feature/AmazingFeature`)\n5. Open a Pull Request\n\n### Development Setup\n\nThe project uses Poetry for dependency management and includes several development tools:\n\n```bash\n# Clone the repository\ngit clone https://github.com/hyperb1iss/git-surgeon\ncd git-surgeon\n\n# Install dependencies\npoetry install\n\n# Run tests\npoetry run pytest\n\n# Run type checking\npoetry run mypy git_surgeon\n\n# Run linting\npoetry run ruff check git_surgeon\n```\n\n## 📄 License\n\nThis project is licensed under the GNU General Public License 2.0 - see the [LICENSE](LICENSE) file for details.\n\n---\n\n\u003cdiv align=\"center\"\u003e\n\nCreated by [Stefanie Jane 🌠](https://github.com/hyperb1iss)\n\nIf you find ChromaCat useful, [buy me a Monster Ultra Violet](https://ko-fi.com/hyperb1iss)! ⚡️\n\n\u003c/div\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhyperb1iss%2Fgit-surgeon","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhyperb1iss%2Fgit-surgeon","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhyperb1iss%2Fgit-surgeon/lists"}