본문 바로가기

Programming/Install & Setting

[Git] remote: error: GH013: Repository rule violations found for refs/heads/main. (민감한 정보 yml)

 

 

팀 프로젝트 이후 CI/CD 실습을 위해

1. 팀 레포지토리에 있던 파일을 IntelliJ 를 통해 Clone Project 하고

2. 개인 레포지토리로 옮겨 Commit/Push

하려고 할 때 생긴 일이다

 

① .git 파일도 손수 지우고 (기존 git 히스토리 삭제)

② git init (.git 파일 생성) 이후

③ 혹시 몰라 git remote remove origin (원격 저장소 삭제)

④ git remote -v (원격 저장소 목록 확인)

까지 확인해 완벽하게 기존 기록을 없애주었다.

 

 

그러나 내가 마주한 건...

PS C:\Users\hi\Desktop\dive-clone\Project-Team-Dive> git push -u origin main
Enumerating objects: 385, done.
Counting objects: 100% (385/385), done.
Delta compression using up to 16 threads
Compressing objects: 100% (367/367), done.
Writing objects: 100% (385/385), 44.72 MiB | 11.76 MiB/s, done.
Total 385 (delta 43), reused 0 (delta 0), pack-reused 0 (from 0)
remote: Resolving deltas: 100% (43/43), done.
remote: error: GH013: Repository rule violations found for refs/heads/main.

 

아무튼 error.

레포지토리 규칙에 의해 거부되었다는 에러였다.

 

이 부분만 따서 검색하면

Ruleset 으로 인해 거부되었음 → 브랜치 규칙 확인해!

라고 뜨던데..

 

Repository → Settings → Rules → Rulesets

 

내 레포지토리에는 규칙이 설정된 게 없었다.

혹시 팀 레포지토리에 있던 규칙이 넘어온건가? 싶었는데

애초에 원격 저장소가 팀 레포지토리에 연결되어 있지 않으니 그건 아닌 것 같았다.

 

그래서 오류 메시지 전문을 살펴본 결과...

 

remote:       ?붴?Amazon AWS Secret Access Key ?붴붴붴붴붴붴붴붴붴붴붴붴붴붴붴붴붴붴붴붴붴?[K

remote:        locations:
remote:          - commit: 
remote:            path: src/main/resources/application.yml:49
remote:
remote:        (?) To push, remove secret from commit(s) or follow this URL to allow the secret.

 

뭐가 주르륵 떠있어서 상세히 봤더니

application.yml 에 AWS 액세스 키가 발견되었고,

깃허브가 민감한 정보로 인식해 푸시를 강제로 막는 것이었다.

민감 정보가 포함된 yml 이 깃에 올라가면 안 된다는 사실을 잠시 잊고 있던 것.

 

역시 해답은 오류 메시지에 있나보다

 

 

git init
git add .
git reset src/main/resources/application.yml
git commit -m "first commit"
git branch -M main
git remote add origin <레포지토리 주소>
git push -u origin main

 

application.yml 만 git add 과정에서 빼주면 되는 것이다.

 

 

 

성공

 

 

 

'Programming > Install & Setting' 카테고리의 다른 글

[ECLIPSE] 웹개발을 위한 이클립스 설치  (0) 2024.11.28