{"id":17237797,"url":"https://github.com/tarao/git-insert-root","last_synced_at":"2026-05-16T22:04:44.193Z","repository":{"id":15055344,"uuid":"17781497","full_name":"tarao/git-insert-root","owner":"tarao","description":"Insert a new root commit on current branch","archived":false,"fork":false,"pushed_at":"2014-03-15T18:18:13.000Z","size":120,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-19T16:55:18.242Z","etag":null,"topics":["git"],"latest_commit_sha":null,"homepage":null,"language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tarao.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-03-15T17:47:39.000Z","updated_at":"2021-03-29T19:49:23.000Z","dependencies_parsed_at":"2022-08-30T05:11:33.503Z","dependency_job_id":null,"html_url":"https://github.com/tarao/git-insert-root","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/tarao/git-insert-root","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tarao%2Fgit-insert-root","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tarao%2Fgit-insert-root/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tarao%2Fgit-insert-root/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tarao%2Fgit-insert-root/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tarao","download_url":"https://codeload.github.com/tarao/git-insert-root/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tarao%2Fgit-insert-root/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266242072,"owners_count":23898102,"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":["git"],"created_at":"2024-10-15T05:43:47.659Z","updated_at":"2026-05-16T22:04:44.161Z","avatar_url":"https://github.com/tarao.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"git insert-root\n===============\n\nInserts a new root commit with optional initial files by\nreconstructing entire commit log of the current branch.\n\n## Installation\n\nPlace ``git-insert-root`` somewhere in your ``PATH``.\n\n## Usage\n\n### Insert an empty root commit\n\n```sh\ngit checkout -b current\ngit insert-root -e\n```\n\n- You will be in ``current`` branch with an empty root commit after ``git insert-root`` command\n- The commit message will be ``(empty)``\n\n### Insert an empty root commit with a message\n\n```sh\ngit insert-root -m \"some message\"\n```\n\n- You will be asked to fill a message if you omit ``-m`` option\n\n### Insert a root commit with initial files\n\n```sh\necho foo \u003e foo.txt\necho bar \u003e bar.txt\ngit insert-root -m \"Initial commit\" foo.txt bar.txt\n```\n\n- Note that you have to prepare the files before running the command\n- Files can be untracked one or some existing file in your branch\n\n### Leaving the root commit branch\n\n```sh\ngit checkout -b current\ngit insert-root -e -b empty\ngit checkout empty\n```\n\n- ``empty`` becomes a branch with a single root commit\n\n## Tips\n\nYou may have a problem with merging from some other branch after\ninserting a root commit.\n\n```sh\ngit checkout branch-A\ngit checkout -b branch-B\ngit insert-root -e\n\ngit checkout branch-A\nvi make-some-change\ngit add make-some-change\ngit commit -m \"make some change\"\n\ngit checkout branch-B\ngit merge branch-A  # CONFLICT!\n```\n\nTo avoid this, make a merge commit just after inserting the root commit.\n\n```sh\ngit checkout branch-A\ngit checkout -b branch-B\ngit insert-root -e\n\ngit merge branch-A  # do this and this should not make conflict\n\ngit checkout branch-A\nvi make-some-change\ngit add make-some-change\ngit commit -m \"make some change\"\n\ngit checkout branch-B\ngit merge branch-A  # this also works\n```\n\n## Acknowledgment\n\nThe idea of implementation is taken from the following insights:\n\n- http://stackoverflow.com/a/15706715\n- http://stackoverflow.com/a/3898842\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftarao%2Fgit-insert-root","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftarao%2Fgit-insert-root","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftarao%2Fgit-insert-root/lists"}