diff --git a/assets/images/help/repository/limit-branches-and-tags-single-push.png b/assets/images/help/repository/limit-branches-and-tags-single-push.png new file mode 100644 index 0000000000..b8b7dfc0eb Binary files /dev/null and b/assets/images/help/repository/limit-branches-and-tags-single-push.png differ diff --git a/assets/images/help/repository/set-limit-branch-tags-single-push.png b/assets/images/help/repository/set-limit-branch-tags-single-push.png new file mode 100644 index 0000000000..0c6a44c9b8 Binary files /dev/null and b/assets/images/help/repository/set-limit-branch-tags-single-push.png differ diff --git a/content/repositories/managing-your-repositorys-settings-and-features/managing-repository-settings/index.md b/content/repositories/managing-your-repositorys-settings-and-features/managing-repository-settings/index.md index 9708ac78d9..3e68171506 100644 --- a/content/repositories/managing-your-repositorys-settings-and-features/managing-repository-settings/index.md +++ b/content/repositories/managing-your-repositorys-settings-and-features/managing-repository-settings/index.md @@ -14,6 +14,7 @@ children: - /managing-the-forking-policy-for-your-repository - /managing-pull-request-reviews-in-your-repository - /managing-the-commit-signoff-policy-for-your-repository + - /managing-the-push-policy-for-your-repository - /managing-git-lfs-objects-in-archives-of-your-repository - /enabling-anonymous-git-read-access-for-a-repository - /about-email-notifications-for-pushes-to-your-repository diff --git a/content/repositories/managing-your-repositorys-settings-and-features/managing-repository-settings/managing-the-push-policy-for-your-repository.md b/content/repositories/managing-your-repositorys-settings-and-features/managing-repository-settings/managing-the-push-policy-for-your-repository.md new file mode 100644 index 0000000000..223f443a50 --- /dev/null +++ b/content/repositories/managing-your-repositorys-settings-and-features/managing-repository-settings/managing-the-push-policy-for-your-repository.md @@ -0,0 +1,37 @@ +--- +title: Managing the push policy for your repository +intro: You can limit how many branches and tags can be updated in a single push. +versions: + feature: limit-branches-tags-in-push +permissions: People with admin permissions for a repository can manage the push policy for the repository. +topics: + - Repositories +shortTitle: Manage the push policy +--- + +## About the push policy + +{% note %} + +**Note:** The push policy is currently in beta and subject to change. + +{% endnote %} + +By default, there is no limit to the number of branches and tags that can be updated in a single push. + +You can limit the number of branches and tags that can be updated in a single push to block potentially destructive pushes. This can prevent or limit the loss of data. + +The push policy also blocks the Git command: `git push --mirror`. This is a potentially destructive command for making the remote exactly match the local clone. When run by accident, it can cause many force-pushes and branch deletions on the remote without any warning. + +## Limiting how many branches and tags can be updated in a single push + +{% data reusables.repositories.navigate-to-repo %} +{% data reusables.repositories.sidebar-settings %} +3. Under "Pushes", select **Limit how many branches and tags can be updated in a single push**. + + ![Screenshot of the limit how many branches and tags can be updated in a single push option](/assets/images/help/repository/limit-branches-and-tags-single-push.png) +4. Enter the number of branches and tags you want to limit in a single push. Lower numbers are more restrictive of which pushes are allowed, and higher numbers are less restrictive but have more potential for being destructive. + + We recommend the default maximum of `5` branch or tag updates allowed in one push. The minimum value is `2`, because Git requires two branch updates to rename a branch in a single push: *delete branch* and *create branch*. + + ![Screenshot of the field where you enter the number of branches and tags you want to limit](/assets/images/help/repository/set-limit-branch-tags-single-push.png) diff --git a/data/features/limit-branches-tags-in-push.yml b/data/features/limit-branches-tags-in-push.yml new file mode 100644 index 0000000000..998ff001ca --- /dev/null +++ b/data/features/limit-branches-tags-in-push.yml @@ -0,0 +1,7 @@ +# Reference: #6046 +# Repo Policies: Admins can block pushes that destructively use --mirror - [GA] +versions: + fpt: '*' + ghec: '*' + ghes: '>=3.7' + ghae: '>=3.7'