[JAVA_Back-End]

[Github] error: src refspec main does not match any 본문

Utilities/Github

[Github] error: src refspec main does not match any

너굴위 2024. 3. 25. 21:02
728x90
반응형

깃허브 에러메세지

 

원래 있는 main 브랜치에 push하려고 했을 때 발생한 에러코드

error: src refspec main does not match any

 

원격저장소와 로컬저장소의 파일 구조가 다를 때 혹은 브랜치의 이름이 다르면 발생할 수 있다.


일단 내가 할 수 있는 해결방법은 3가지였다.

 

1. pull을 먼저 시도하고 다시 push를 진행한다.

 

2. 강제적으로 push한다. 

=> 매우 위험하다. 기존 원격자료가 없어질 수 있기 때문이다.

 

3. 브랜치 새로 생성 후 해당 브랜치에 push한다.


혹시나 브랜치의 이름이 다른 건 아닐까 해서 로컬 저장소의 브랜치명을 확인했다.

$ git show-ref

 

Github에서 Repository를 생성하면 default로 main브랜치가 생성되기 때문에 당연히 main이겠거니 했지만,

master로 생성되어 있었다.

 

Solution

=> TERMINAL을 통해 master에서 main으로 브랜치 이름 변경

$ git branch -m master main

 

해결완료!

728x90
반응형