{"id":15653128,"url":"https://github.com/ethomson/retarget_prs","last_synced_at":"2025-04-30T21:10:18.310Z","repository":{"id":42805234,"uuid":"270688244","full_name":"ethomson/retarget_prs","owner":"ethomson","description":"A project to batch update the base of PRs","archived":false,"fork":false,"pushed_at":"2022-03-26T21:04:29.000Z","size":516,"stargazers_count":30,"open_issues_count":2,"forks_count":3,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-26T01:43:40.856Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/ethomson.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-06-08T13:55:51.000Z","updated_at":"2023-11-20T23:18:49.000Z","dependencies_parsed_at":"2022-08-22T07:10:43.212Z","dependency_job_id":null,"html_url":"https://github.com/ethomson/retarget_prs","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ethomson%2Fretarget_prs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ethomson%2Fretarget_prs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ethomson%2Fretarget_prs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ethomson%2Fretarget_prs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ethomson","download_url":"https://codeload.github.com/ethomson/retarget_prs/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251782776,"owners_count":21642987,"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":[],"created_at":"2024-10-03T12:44:46.359Z","updated_at":"2025-04-30T21:10:18.290Z","avatar_url":"https://github.com/ethomson.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# retarget_prs\n\n![Master to Main](docs/master_to_main.gif)\n\nThis utility will change the base of all the pull requests in your GitHub repository that are currently targeting a different branch.  This is useful if you want to [change the name of your default branch](https://www.hanselman.com/blog/EasilyRenameYourGitDefaultBranchFromMasterToMain.aspx), but you have pull requests open.\n\nFor example, if you use the _default_ default branch of `master`, but you want to change that to a name like `main`, by default the pull requests that you already have open in your repository will continue to target the old default branch (`master`).\n\nFortunately, you can [change the base of an existing pull request](https://github.blog/2016-08-15-change-the-base-branch-of-a-pull-request/), but this is a one-at-a-time, manual operation.\n\nThis utility will automate that, and make this change en masse.\n\n## Setup\n\n1. Ensure that you have [Node.js](https://nodejs.org/en/download/) installed.\n2. Create a [personal access token](https://help.github.com/en/github/authenticating-to-github/creating-a-personal-access-token-for-the-command-line) to use to authenticate.\n\n## How to\n\nIf you want to change the name of the default branch on GitHub:\n\n1. Go to your project and make sure that you are on the current default branch (`master`).  Open the branch picker, and type the name of the new branch (`main`).  Select `Create branch: main from 'master'`.\n\n   ![Create new branch](docs/newbranch.png)\n\n2. Set this as the new default branch.  Go to your project's settings, then select \"Branches\".  Under \"Default branch\", open the branch picker and select the new default branch (`main`).\n\n   ![Set the new default](docs/newdefault.png)\n\n3. Update the existing pull requests.  Specify your PAT with `--token`, your repository URL and the old and new branch names:\n\n   ```\n   npx retarget_prs --token your_pat https://github.com/your/repo master main\n   ```\n\n## Questions?\n\nNeed help?  [Open a GitHub issue](https://github.com/ethomson/retarget_prs).\n\n## License\n\nCopyright (c), Edward Thomson.  All rights reserved.\n\nAvailable under the MIT license, see the included [LICENSE.txt](LICENSE.txt) for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fethomson%2Fretarget_prs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fethomson%2Fretarget_prs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fethomson%2Fretarget_prs/lists"}