github branch 분기 보호하기

YeongMin·2023년 7월 12일
1

git

목록 보기
1/2
remote: - Changes must be made through a pull request.
remote: 
remote: - Cannot change this locked branch

이렇게 터미널에 주의 문구는 알려주지만 실제로 remote branch를 보게되면 push 가 이루어진 것을 알 수 있습니다.

추측하건데

내가 우회 권한이 있는 관리자여서 이게 가능한 것이 아닌가? 라는 생각을 하게 되었고 해당 옵션을 활성화 시켜보았습니다.

remote: error: GH006: Protected branch update failed for refs/heads/develop.
remote: error: Changes must be made through a pull request. Cannot change this locked branch
To https://github.com/ttbranch/tt01.git
 ! [remote rejected] develop -> develop (protected branch hook declined)
error: 레퍼런스를 'https://github.com/ttbranch/tt01.git'에 푸시하는데 실패했습니다

드디어 원하는 결과물이 나왔습니다.
단순히 warning이 아닌 error를 일으키게 하여 push에 실패하게 되었습니다.

feat/1 이라는 브랜치를 생성하고
commit, push를 한 다음에

develop으로 돌아가서 pull(fetch, merge)를 해보기로 했습니다.

로컬에서는 이를 막지 못하는것으로 보입니다. 어떻게보면 당연한 결과일수도 있습니다.

우리가 적용한 저 분기보호는 github remote repo에만 적용이 되는 것이니까요

그럼 만일 로컬에서 이런 실수를 진행했을 때 conflict를 해결하고 develop에 push를 하게 된다면?

remote: error: GH006: Protected branch update failed for refs/heads/develop.
remote: error: Changes must be made through a pull request. Cannot change this locked branch
To https://github.com/ttbranch/tt01.git
 ! [remote rejected] develop -> develop (protected branch hook declined)
error: 레퍼런스를 'https://github.com/ttbranch/tt01.git'에 푸시하는데 실패했습니다

다행입니다... 이루어지지 않는군요
결국 가장 중요한 핵심은 분기보호 규칙을 적요한 브랜치에 직접적인 push가 일어나지 않게 하는 것이었습니다.

그럼 작업자는 아 내가 뭔가 잘못했구나 하고 상황을 판단하고 로컬에서의 pull 작업을 reset 혹은 revert 한 다음 진행하면 됩니다.

profile
Front-End 안영민

0개의 댓글