Gitでmasterブランチに強制push(force-push)させないようにするには

複数人でGitを更新していると絶対に訪れる失敗

「あ、間違えてmasterブランチにpushしちゃった><」

こんな失敗が起きないように、Githubの設定を変更していくことをオススメします。

Githubの「settings」タブを開いて以下を選択して設定しましょう。

英語で書かれているため、わからないかもしれないため、Google翻訳にかけてみたのと補足を入れました
✅がついているものに関しては設定を入れると良いと感じています。

Protect matching branches

一致するブランチを保護する
Disables force-pushes to all matching branches and prevents them from being deleted. Force-pushes to the default branch have been disabled by your GitHub Enterprise administrator. Please contact them if you’d like that changed.
一致するすべてのブランチへの強制プッシュを無効にし、それらが削除されるのを防ぎます。 デフォルトのブランチへの強制プッシュは、GitHub Enterprise管理者によって無効にされています。変更したい場合は連絡してください。

Require pull request reviews before merging

マージする前にプルリクエストのレビューを要求する
When enabled, all commits must be made to a non-protected branch and submitted via a pull request with the required number of approving reviews and no changes requested before it can be merged into a branch that matches this rule.
有効になっている場合、すべてのコミットは保護されていないブランチに対して行われ、プルリクエストを介して送信され、必要な数の承認レビューがあり、このルールに一致するブランチにマージする前に変更は要求されません。
プルリクする際に、設定した人数のapproveがないとマージができないようになります。
Dismiss stale pull request approvals when new commits are pushed
新しいコミットがプッシュされたときに古いプルリクエストの承認を却下する
New reviewable commits pushed to a matching branch will dismiss pull request review approvals.
一致するブランチにプッシュされた新しいレビュー可能なコミットは、プルリクエストのレビュー承認を却下します。
Require review from Code Owners
コード所有者からのレビューを要求する
Require an approved review in pull requests including files with a designated code owner.
指定されたコード所有者のファイルを含むプルリクエストでは、承認されたレビューが必要です。
Restrict who can dismiss pull request reviews
プルリクエストのレビューを却下できるユーザーを制限する
Specify people or teams allowed to dismiss pull request reviews.
プルリクエストのレビューの却下を許可するユーザーまたはチームを指定します。

Require status checks to pass before merging

マージする前にステータスチェックに合格する必要があります
Choose which status checks must pass before branches can be merged into a branch that matches this rule. When enabled, commits must first be pushed to another branch, then merged or pushed directly to a branch that matches this rule after status checks have passed.
ブランチをこのルールに一致するブランチにマージする前に、どのステータスチェックに合格する必要があるかを選択します。有効にした場合、コミットを最初に別のブランチにプッシュしてから、ステータスチェックに合格した後で、このルールに一致するブランチに直接マージまたはプッシュする必要があります。
jenkinsなどでステータスチェックをしている場合はやるべきです。

Require signed commits

署名されたコミットが必要
Commits pushed to matching branches must have verified signatures.
一致するブランチにプッシュされたコミットには、署名が検証されている必要があります。

    ✅Include administrators

    管理者を含める
    Enforce all configured restrictions for administrators.
    管理者に対して構成されたすべての制限を適用します。
    これをいれておかないと、自分が管理者だった場合、自分はforce-pushできてしまうので、入れておいたほうがいいです。

    Restrict who can push to matching branches

    一致するブランチにプッシュできるユーザーを制限する
    Specify people, teams or apps allowed to push to matching branches. Required status checks will still prevent these people, teams and apps from merging if the checks fail.
    一致するブランチにプッシュできるユーザー、チーム、またはアプリを指定します。必要なステータスチェックは、チェックが失敗した場合でも、これらの人々、チーム、アプリがマージすることを防ぎます。

    Fatal error: Uncaught Error: Call to undefined function set_post_views() in /home/jszk/desnote.com/public_html/wpjs/wp-content/themes/the-thor-child/single.php:658 Stack trace: #0 /home/jszk/desnote.com/public_html/wpjs/wp-includes/template-loader.php(78): include() #1 /home/jszk/desnote.com/public_html/wpjs/wp-blog-header.php(19): require_once('/home/jszk/desn...') #2 /home/jszk/desnote.com/public_html/index.php(17): require('/home/jszk/desn...') #3 {main} thrown in /home/jszk/desnote.com/public_html/wpjs/wp-content/themes/the-thor-child/single.php on line 658