Skip to content

Create orphan branch using octokit api #1984 #24699

Discussion options

You must be logged in to vote

Hello, @techierishi. Is this a solution for you?
Inspired by Python script to create an orphan branch · GitHub and the suggestion in the gist

// > Git has a well-known, or at least sort-of-well-known, empty tree whose SHA1 ...
// https://stackoverflow.com/questions/9765453
const SHA1_EMPTY_TREE = "4b825dc642cb6eb9a060e54bf8d69288fbee4904";

const owner = 'xxx'
const repo = 'yyy'

const octokit = new Octokit({ auth: token });
const res = await octokit.request("POST /repos/{owner}/{repo}/git/commits", {
owner,
repo,
message: "orp branch initial commit",
tree: SHA1_EMPTY_TREE,
parents: [],
});
await octokit.request("POST /repos/{owner}/{repo}/git/refs", {
owner,
repo,
// If it doesn't start wi…

Replies: 4 comments

Comment options

You must be logged in to vote
0 replies
Answer selected
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment