왕논의 연구실

[Git] error: src refspec main does not match any 해결방법 본문

Git

[Git] error: src refspec main does not match any 해결방법

ywangnon 2022. 5. 25. 16:28

git push origin main을 입력하니까 error: src refspec main does not match any 에러 출력 됨

 

시도 1

추측원인: 위의 에러는 변경사항이 없는데 push 하려고 할 때 일어나는 경우가 있음

  • add, commit 이 제대로 안된 것이라 생각되어 다시 시도 -> 실패

 

시도 2

추측원인: 현재 github의 기본 branch는 main임. git init시 생성되는 기본 브런치는 master임 브랜치가 달라서 위의 에러가 일어나는 경우가 있음.

  • git show-ref 입력

head가 master와 main으로 다른 것을 확인함

  • git branch를 입력하여 branch가 master인 것을 확인함
  • git branch -m master main 로 branch 수정
  • git push origin main 으로 push -> 성공

 

참고

https://www.hahwul.com/2021/07/17/changing-the-github-default-branch/

 

https://stackoverflow.com/questions/4181861/message-src-refspec-master-does-not-match-any-when-pushing-commits-in-git