1.6 KiB
title, intro, product, versions
| title | intro | product | versions | ||||||
|---|---|---|---|---|---|---|---|---|---|
| Requiring a linear commit history | You can require a linear commit history to block all merge commits from a protected branch. | {% data reusables.gated-features.protected-branches %} |
|
Anyone with admin permissions to a repository can require a linear commit history.
About enforcement of linear commit history
Enforcing a linear commit history prevents merge commits from being pushed to the protected branch. This means that any pull requests merged into the protected branch must use a squash merge or a rebase merge. A strictly linear commit history can help teams backtrack changes more efficiently. For more information about merge methods, see "About pull request merges."
{% data reusables.repositories.protected-branches-options %}
Before you can require a linear commit history, your repository must allow squash merging or rebase merging. For more information, see "Configuring pull request merges."
Enforcing a linear commit history
{% data reusables.repositories.navigate-to-repo %}
{% data reusables.repositories.sidebar-settings %}
{% data reusables.repositories.repository-branches %}
{% data reusables.repositories.add-branch-protection-rules %}
6. Under "Protect matching branches", select Require linear history.
{% data reusables.repositories.include-administrators %}
7. Click Create.