{"id":13898125,"url":"https://github.com/gr2m/octokit-plugin-rename-branch","last_synced_at":"2025-07-17T15:32:13.765Z","repository":{"id":46650446,"uuid":"158443328","full_name":"gr2m/octokit-plugin-rename-branch","owner":"gr2m","description":"Octokit plugin to rename a branch in a github repository","archived":true,"fork":false,"pushed_at":"2021-10-22T20:52:53.000Z","size":12281,"stargazers_count":19,"open_issues_count":7,"forks_count":1,"subscribers_count":5,"default_branch":"main","last_synced_at":"2024-10-29T23:51:09.074Z","etag":null,"topics":["javascript","octokit","plugin"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","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/gr2m.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-11-20T19:51:14.000Z","updated_at":"2024-03-21T18:28:02.000Z","dependencies_parsed_at":"2022-09-20T23:10:47.764Z","dependency_job_id":null,"html_url":"https://github.com/gr2m/octokit-plugin-rename-branch","commit_stats":null,"previous_names":["gr2m/octokit-rename-branch"],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gr2m%2Foctokit-plugin-rename-branch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gr2m%2Foctokit-plugin-rename-branch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gr2m%2Foctokit-plugin-rename-branch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gr2m%2Foctokit-plugin-rename-branch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gr2m","download_url":"https://codeload.github.com/gr2m/octokit-plugin-rename-branch/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":226084284,"owners_count":17571150,"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":["javascript","octokit","plugin"],"created_at":"2024-08-06T18:04:05.776Z","updated_at":"2024-11-25T04:30:42.625Z","avatar_url":"https://github.com/gr2m.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"# ⚠️ This plugin has been archived.\n\nGitHub introduced an [API to rename a branch](https://docs.github.com/en/rest/reference/repos#rename-a-branch) which implements most, if not all, what this plugin used to do.\n\n# octokit-plugin-rename-branch\n\n\u003e Octokit plugin to rename a branch in a github repository\n\n[![@latest](https://img.shields.io/npm/v/octokit-plugin-rename-branch.svg)](https://www.npmjs.com/package/octokit-plugin-rename-branch)\n[![Build Status](https://github.com/gr2m/octokit-plugin-rename-branch/workflows/Test/badge.svg)](https://github.com/gr2m/octokit-plugin-rename-branch/actions?query=workflow%3ATest+branch%3Amain)\n\n## Usage\n\n\u003ctable\u003e\n\u003ctbody valign=top align=left\u003e\n\u003ctr\u003e\u003cth\u003e\nBrowsers\n\u003c/th\u003e\u003ctd width=100%\u003e\n\nLoad `octokit-plugin-rename-branch` and [`@octokit/core`](https://github.com/octokit/core.js) (or core-compatible module) directly from [cdn.pika.dev](https://cdn.pika.dev)\n\n```html\n\u003cscript type=\"module\"\u003e\n  import { Octokit } from \"https://cdn.pika.dev/@octokit/core\";\n  import {\n    renameBranch,\n    composeRenameBranch,\n  } from \"https://cdn.pika.dev/octokit-plugin-rename-branch\";\n\u003c/script\u003e\n```\n\n\u003c/td\u003e\u003c/tr\u003e\n\u003ctr\u003e\u003cth\u003e\nNode\n\u003c/th\u003e\u003ctd\u003e\n\nInstall with `npm install @octokit/core octokit-plugin-rename-branch`. Optionally replace `@octokit/core` with a core-compatible module\n\n```js\nconst { Octokit } = require(\"@octokit/core\");\nconst {\n  renameBranch,\n  composeRenameBranch,\n} = require(\"octokit-plugin-rename-branch\");\n```\n\n\u003c/td\u003e\u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\n```js\nconst MyOctokit = Octokit.plugin(renameBranch);\nconst octokit = new MyOctokit({\n  // create token at https://github.com/settings/tokens/new\n  auth: \"my-token-123\",\n});\n\noctokit.renameBranch({\n  owner: \"octocat\",\n  repo: \"hello-world\",\n  current_name: \"master\",\n  name: \"main\",\n});\n```\n\nYou can use `composeRenameBranch` directly, too.\n\n```js\ncomposeRenameBranch(octokit, {\n  owner: \"octocat\",\n  repo: \"hello-world\",\n  current_name: \"master\",\n  name: \"main\",\n});\n```\n\n## How it works\n\n1. Creates a new reference using the `sha` of the last commit of `current_branch`\n   ([`POST /repos/:owner/:repo/git/refs`](https://developer.github.com/v3/git/refs/#create-a-reference))\n2. Updates the default branch of the repository ([`PATCH /repos/:owner/:repo`](https://developer.github.com/v3/repos/#edit))\n3. Updates branch protection to the new branch name if applicable ([GraphQL mutation `updateBranchProtectionRule`](https://developer.github.com/v4/mutation/updatebranchprotectionrule/))\n4. Look for open pull requests and update the base branch if it’s `current_branch` ([`PATCH /repos/:owner/:repo/pulls/:pull_number`](https://developer.github.com/v3/pulls/#update-a-pull-request))\n5. Delete `current_branch` ([`DELETE /repos/:owner/:repo/git/refs/:ref`](https://developer.github.com/v3/git/refs/#delete-a-reference))\n\n## Motivation\n\nThis library is meant to simplify the process of renaming branch names of GitHub repositories.\n\nBy default, both Git and GitHub use `master` for their main branch. I think Git \u0026 GitHub should follow the lead of tech communities such as [Django](https://github.com/django/django/pull/2692), [Drupal](https://www.drupal.org/project/drupal/issues/2275877) and [CouchDB](https://issues.apache.org/jira/browse/COUCHDB-2248) and replace `master` with non-offensive term, such as `latest` or `main`.\n\n## License\n\n[MIT](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgr2m%2Foctokit-plugin-rename-branch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgr2m%2Foctokit-plugin-rename-branch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgr2m%2Foctokit-plugin-rename-branch/lists"}