Publicamos atualizações frequentes em nossa documentação, e a tradução desta página ainda pode estar em andamento. Para obter as informações mais recentes, acesse a documentação em inglês. Se houver problemas com a tradução desta página, entre em contato conosco.
Versão do artigo: Enterprise Server 2.20

Requiring a linear commit history

You can require a linear commit history to block all merge commits from a protected branch.

Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server.

Neste artigo

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."

You can automatically enforce protected branch settings for some or all branches in your repository. Para obter mais informações, consulte "Configurar branches protegidos".

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

  1. No GitHub Enterprise, navegue até a página principal do repositório.
  2. Under your repository name, click Settings.
    Repository settings button
  3. In the left menu, click Branches.
    Repository options sub-menu
  4. Next to "Branch protection rules", click Add rule.
    Add branch protection rule button
  5. Under "Branch name pattern", type the branch name or pattern you want to protect.
    Branch rule field
  6. Under "Protect matching branches", select Require linear history.
    Required linear history option
  7. Outra opção é selecionar Include administrators (Incluir administradores). This enforces all configured restrictions for repository administrators.
    Caixa de seleção Include administrators (Incluir administradores)
  8. Click Create.

Pergunte a uma pessoa

Não consegue encontrar o que procura?

Entrar em contato