git push error because it will make the index and work tree inconsistent , refusing to update checked out branch: refs/heads/master

git push시 아래와 같은 오류가 발생했다

 

 

remote: error: refusing to update checked out branch: refs/heads/master

remote: error: By default, updating the current branch in a non-bare repository

remote: error: is denied, because it will make the index and work tree inconsistent

remote: error: with what you pushed, and will require 'git reset --hard' to match

remote: error: the work tree to HEAD.

remote: error:

remote: error: You can set 'receive.denyCurrentBranch' configuration variable to

remote: error: 'ignore' or 'warn' in the remote repository to allow pushing into

remote: error: its current branch; however, this is not recommended unless you

remote: error: arranged to update its work tree to match what you pushed in some

remote: error: other way.

remote: error:

remote: error: To squelch this message and still keep the default behaviour, set

remote: error: 'receive.denyCurrentBranch' configuration variable to 'refuse'.

 

 

원인과 해결방법

 

우리가 처음 만든 중앙 저장소와 현재 저장소의 같은 branch "로그인"되어 있기 때문입니다. 따라서 중앙 저장소의 현재 branch를 다른 것으로 바꾸어 주면 문제는 해결됩니다.

 

 

git checkout -b 'other'   //브랜치 생성 후 체크아웃, 아래 명령어 2줄을 1줄로 줄인 것

 

또는,

 

git branch ‘other’

git checkout ‘other’

댓글

Designed by JB FACTORY