본문 바로가기
퍼블리셔/여러가지 꿀팁

git 원격 브랜치와 로컬 브랜치 이름이 일치하지 않을때 에러 해결

by 영니_ 2023. 7. 4.
반응형

현생......에서 이런저런 오류를 만나는데, 이제는 기록하고 기억하려고 
블로그에 남기기로 결심했습니다!! 허허, 아직도 현생에 치여서 블로그 관리는 잘 못하겠지만 

들리시는 분들께 유용한 정보가 있는 블로그가 되길! 

 

git branch 이름을 바꿀때가 한번쯤은? 있을겁니다..! 

 

git branch name 변경 방법

 

1. 변경하고 싶은 브랜치로 이동

git checkout new-branch

 

2. branch -m 옵션으로 브랜치 이름 변경

git branch -m change-name

 

git push를 하려다가 보면 해당 에러랑 마주칠 때가 있는데
(현재 분기의 업스트림 분기가 일치하지 않습니다. 현재 지점의 이름입니다)

fatal: The upstream branch of your current branch does not match
the name of your current branch.  To push to the upstream branch
on the remote, use

    git push origin HEAD:new-branch

To push to the branch of the same name on the remote, use

    git push origin HEAD

To choose either option permanently, see push.default in 'git help config'.

To avoid automatically configuring an upstream branch when its name
won't match the local branch, see option 'simple' of branch.autoSetupMerge
in 'git help config'.

 

해결 방법은 아래와 같습니다.

(업스트림 분기를 현재 바뀐 브랜치 명으로 설정)

git branch --set-upstream-to=origin/change-name change-name
반응형

댓글