상세 컨텐츠

본문 제목

[Git] src refspec [branch_name] does not match any error

개발 기타 지식들/Extra Knowledge

by bydawn25 2022. 2. 10. 08:05

본문

push 명령어를 특정 브랜치에 실행할때 아래와 같은 오류가 나는 경우가 있다.

 

$ git push origin [specific_branch_name] 
error: src refspec [specific_branch_name] does not match any
error : failed to push some refs to 'ssh://git.juso.co.kr/juso.git'

 

 

 

 

 

이 오류를 해결하기 위한 몇가지 경우의 수가 있다.

1. pull 먼저하기

$ git pull origin [specific_branch_name] 

내가 push하고자 하는 목적지의 branch가 지금 내 local의 상태와 일치하지 않아서 생기는 문제일 수 있다. 위와 같은 명령어로 해결 가능하다.

 

단 위와 같이 pull 명령어를 통해 폴더의 상태를 일치시키고자 했을때 git이 자동으로 merge하지 못한다면 수동으로 merge해줘야 한다.

 

2. commit하기 

$ git commit -m "message to push"

현재 내가 push하고자 하는 내용이 없어서 나는 에러일 수 있다.

 

3. push하고자 하는 branch와 일치하는 branch를 local에도 만들기

$ git branch [specific_branch_name]
$ git checkout [specific_branch_name]

내가 push하고자 하는 목적지의 branch와 내가 지금 작업하는 branch의 이름이 일치하지 않아서 생기는 문제일 수도 있다. 그럴때는 pull을 통해 master의 상태를 origin과 동일하게 만들고 동일한 이름의 branch를 만들어서 checkout하면 정상적으로 push가 되는 것을 확인할 수 있다.

 

나는 희한하게 이 경우가 많았다😄

 

 

 

 

 

알면알수록 어려운 깃...

 

 

 

 

 

관련글 더보기