- Githubでdevelop -> masterへのマージをPullRequestでやろうとして、マージ後にうっかり削除してしまった場合があるので、その防止
手順(例:developを削除しないようにする)
1 リポジトリの「Settings」を選択
2 「Branches」を選択し、「Protected branches」の「Choose a branch」コンボボックスから、削除させたくないブランチ(ここではdevelop)を選択
3 「Protected this branch」にチェックを入れて、「Save changes」ボタンを押下する
4 「Protected branches」にdevelopブランチが入った
5 この状態でPullRequestして、develop -> masterへのマージをすると、マージ後にブランチ削除のボタンが出ない
- ちなみにgitコマンドでも削除できない
git push --delete origin develop
remote: error: GH006: Protected branch update failed for refs/heads/develop.
remote: error: Cannot delete a protected branch
To git@github.com:xxx/hoge.git
! [remote rejected] develop (protected branch hook declined)
error: failed to push some refs to 'git@github.com:xxx/hoge.git'