error: src refspec main does not match any / error: failed to push some refs to - 해결 방법

fejigu·2023년 2월 21일
4

Error Message

목록 보기
10/10
post-thumbnail


🔥 에러 메세지

👉🏻 전일 작업에 이어서 금일 작업을 하고 github repository에 push를 하기 위해 git push origin main 명령어를 입력하니, error: src refspec main does not match any, error: failed to push some refs to와 같은 에러 메세지를 마주하게 되었다.




👾 원인

👉🏻 구글링을 해보니, 위와 같은 에러 메세지는 원격저장소(github)에 내 로컬(PC)에는 없는 파일이 있을때, 내 파일을 push 하면 발생하는 오류라고 한다.

그러니 원격 저장소에서 내 로컬에 저장하지 않은 파일을 pull을 먼저 한 후, 다시 원격저장소에 다시 push를 해야하는 것이였다.




🔎 해결 방법

👉🏻 찾아보니 두 가지 방법으로 오류를 해결하고, git push를 할 수 있었다. 오류 해결 완료!!

//첫번째 해결 방법
git pull origin main
git push origin main
//두전째 해결 방법
git init
git add .
git commit -m "커밋 메세지"
git remote add origin "repository 주소"
git push -u origin main 
profile
console.log(frontendjigu( ☕️, 📱); // true

0개의 댓글