Work with branches
Create and manage documentation branches to preview changes, collaborate with teammates, and merge updates before publishing to production.
Branches are a feature of version control that point to specific commits in your repository. Your deployment branch, usually called main, represents the content used to build your live documentation site. All other branches are independent of your live docs unless you choose to merge them into your deployment branch.
Branches let you create separate instances of your documentation to make changes, get reviews, and try new approaches before publishing. Your team can work on branches to update different parts of your documentation simultaneously without affecting what users see on your live site.
The following diagram shows an example of a branch workflow where you create a feature branch, make changes, and then merge the feature branch into the main branch.
Always work from branches when updating documentation to keep your live site stable and enable review workflows.
Branch naming conventions
Use clear, descriptive names that explain the purpose of a branch.
Use:
fix-broken-linksadd-webhooks-guidereorganize-getting-startedticket-123-oauth-guide
Avoid:
tempmy-branchupdatesbranch1
Create a branch
- Click the branch name in the editor toolbar.
- Click Create new branch.
- Enter a descriptive name.
- If you have unsaved changes, choose whether to bring them to the new branch or leave them on your current branch.
- Click Create branch.
Create a branch from your terminal
git checkout -b branch-nameThis creates the branch and switches to it in one command.
Push the branch to GitHub
git push -u origin branch-nameThe -u flag sets up tracking so future pushes just need git push.
Save changes on a branch
Click the Save as commit button in the top-right of the editor toolbar. This creates a commit and pushes your work to your branch automatically.
Stage, commit, and push your changes.
git add .
git commit -m "Describe your changes"
git pushSwitch branches
- Click the branch name in the editor toolbar to open the branch dropdown.
- Search for a branch by name or scroll through the list.
- Click the branch you want to switch to.
Each branch in the dropdown displays a status indicator so you can see whether it is ready, syncing, or failed.
Unsaved changes are lost when switching branches. Save your work first.
Switch to an existing branch:
git checkout branch-nameOr create and switch in one command:
git checkout -b new-branch-nameMerge branches
Once your changes are ready to publish, create a pull request to merge your branch into the deployment branch.