{"id":27403899,"url":"https://github.com/pmav99/git-rewrite","last_synced_at":"2026-05-16T08:41:49.989Z","repository":{"id":51351932,"uuid":"191365869","full_name":"pmav99/git-rewrite","owner":"pmav99","description":"  A script that helps you rewrite git history (but doesn't do it for you!)","archived":false,"fork":false,"pushed_at":"2021-05-13T21:02:02.000Z","size":103,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-09T16:45:48.900Z","etag":null,"topics":["cli","git","history","python","rewrite"],"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/pmav99.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}},"created_at":"2019-06-11T12:20:33.000Z","updated_at":"2021-04-06T21:43:01.000Z","dependencies_parsed_at":"2022-08-26T08:02:00.002Z","dependency_job_id":null,"html_url":"https://github.com/pmav99/git-rewrite","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/pmav99/git-rewrite","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pmav99%2Fgit-rewrite","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pmav99%2Fgit-rewrite/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pmav99%2Fgit-rewrite/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pmav99%2Fgit-rewrite/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pmav99","download_url":"https://codeload.github.com/pmav99/git-rewrite/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pmav99%2Fgit-rewrite/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266699636,"owners_count":23970534,"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","status":"online","status_checked_at":"2025-07-23T02:00:09.312Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"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":["cli","git","history","python","rewrite"],"created_at":"2025-04-14T04:55:52.240Z","updated_at":"2026-05-16T08:41:44.966Z","avatar_url":"https://github.com/pmav99.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![tests](https://github.com/pmav99/git-rewrite/actions/workflows/test.yml/badge.svg)](https://github.com/pmav99/git-rewrite/actions/workflows/test.yml)\n\ngit-rewrite\n===========\n\nA script that helps you rewrite git history (but doesn't do it for you!)\n\n## Disclaimer\n\n*Use this at your own risk*\n\n(but is should be rather safe to do so)\n\n## Introduction\n\nEditing `GIT_AUTHOR` and `GIT_COMMITTER` data for multiple commits can be a pain.\nEditing dates even more so.\n\nThis script tries to make the process somewhat easier. It works by creating a new branch,\napplying the changes there and letting the user to actually decide if he wants to keep\nthe branch or throw it away.\n\nThe supported fields are:\n\n- `AUTHOR_NAME`\n- `AUTHOR_EMAIL`\n- `AUTHOR_DATE`\n- `COMMITTER_NAME`\n- `COMMITTER_EMAIL`\n- `COMMITTER_DATE`\n\n## Example\n\nLet's assume that we have the following repo and that we want to change the AUTHOR data\nfor commits `C` and `D`\n\n```\n                                  HEAD\n                                   |\n                                   *\nA ---\u003e B ---\u003e C ---\u003e D ---\u003e E ---\u003e F\n```\n\n\nRunning this script will:\n\n1. checkout `B`\n2. create a new branch\n3. cherry-pick commits: `C`, `D`, `E` and `F`\n4. edit `AUTHOR` and `COMMITER` data on each commit with `git commit --amend`\n\nSo, after running the script our repo should look like this:\n\n```\nA ---\u003e B ---\u003e C ---\u003e D ---\u003e E ---\u003e F  (original-branch)\n       |\n       -----\u003e C' --\u003e D' --\u003e E' --\u003e F' (new-branch)\n```\n\nIt is now up to us to ensure that everything is looking OK and actually overwrite\nhistory with e.g.:\n\n```\ngit checkout original-branch\ngit reset --hard new-branch\ngit push\n```\n\n## Installation\n\nThe recommended installation method is [pipx](https://github.com/pipxproject/pipx).  More\nspecifically, you can install `git-rewrite` for your user with:\n\n```\npipx install --spec https://github.com/pmav99/git-rewrite/archive/master.zip git-rewrite\n```\n\nThe above command will create a virtual environment in `~/.local/pipx/venvs/git-rewrite`\nand add the `git-rewrite` script in `~/.local/bin`.\n\n\n## Command overview\n\nThe script has two subcommands:\n\n- `git-rewrite dump`\n- `git-rewrite apply`\n\nBoth are required.\n\nThe `dump` step saves the commit data of the current history to a JSON file.\nYou are supposed to manually edit the file and make any changes you need (e.g. using `sed`).\nAfter you are done, you just `apply` the changes to the repo.\n\n### How the `dump` works\n\nThe `dump` script\n\n1. generates a list of commit hashes since the root commit using:\n\n``` bash\ngit rev-list --ancestry-path a84477f..HEAD\n```\n\n2. parses the commit data of each commit using `git show --format=fuller` and saves them\n   to a JSON file.\n\nThe end result is something like this:\n\n``` JSON\n\n{\n  \"root_hash\": \"a84477f\",\n  \"commits\": [\n    {\n      \"commit_hash\": \"6726ad10be585c21c38726630f7dadf85833f10f\",\n      \"author_name\": \"John Doe\",\n      \"author_email\": \"john_doe@gmail.com\",\n      \"author_date\": \"Thu Jun 6 15:51:30 2019 +0300\",\n      \"committer_name\": \"john Doe\",\n      \"committer_email\": \"john_doe@gmail.com\",\n      \"committer_date\": \"Thu Jun 6 15:53:56 2019 +0300\"\n    },\n    {\n      \"commit_hash\": \"4bf077761d21090b46f178b5da534fb9a9da0ca9\",\n      \"author_name\": \"John Doe\",\n      \"author_email\": \"john_doe@gmail.com\",\n      \"author_date\": \"Thu Jun 6 18:12:34 2019 +0300\",\n      \"committer_name\": \"John Doe\",\n      \"committer_email\": \"john_doe@gmail.com\",\n      \"committer_date\": \"Thu Jun 6 18:12:34 2019 +0300\"\n    }\n  ]\n}\n\n```\n\n### How the `apply` works\n\n1. the script checkouts the root commit and creates a new branch.\n2. For each commit in the JSON file the script runs:\n\n    1. `git cherry-pick` it in order to bring the changeset into the new branch\n    2. `git commit --amend ...` in order to update the `AUTHOR` and the `COMMITTER`\n       data.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpmav99%2Fgit-rewrite","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpmav99%2Fgit-rewrite","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpmav99%2Fgit-rewrite/lists"}