Commit a File to a New Branch
A 3-step recipe with GitHub. We can help you get access.
Recipe · 3 steps
Commit a File to a New Branch
with GitHub · Software Construction Management
Create a branch from a base ref and commit a file to it.
- Read the base branch reference to obtain the commit SHA the new branch will point at.
- Create the new branch reference pointing at the base commit SHA returned by the previous step.
- Create the file on the new branch in a single commit.
What you'll need to have ready
- githubToken: A GitHub token with repo scope, passed as a Bearer credential.
- owner: The account owner of the repository.
- repo: The name of the repository.
- baseBranch: The base branch name to branch from (e.g. main), without the heads/ prefix.
- newBranch: The new branch name to create, without the heads/ prefix.
- path: The repository path of the file to create.
- message: The commit message.
- contentBase64: The new file content, Base64 encoded.
For your developer
Arazzo workflow github:commit-file-to-new-branch, 3 operations: git/get-ref → git/create-ref → repos/create-or-update-file-contents. Specs on APIs.io.