git pull – error: cannot lock ref

pull 받으려고 `git pull` 했더니, 오류 메시지만 반환.

error : cannot lock ref ‘refs/remotes/origin/xxxxxx branch’: is at xxxxxxxxxxxxxxxxx but expected yyyyyyyyyyy

remote 브랜치 중에 뭔가 강제로 변경된 부분이 있는데, local 브랜치의 ref정보와 달라서 제대로 pull을 못받는 현상이 발생한 것으로 보임.

강제로 원격 브랜치 정보로 로컬 브랜치 ref를 업데이트 해준다.  (local에 유효하지 않은 것을 제거)

아래 두 명령어 모두 동일하게 작동.

> git remote prune origin
> git fetch --prune

위의 명령어로 local ref정보를 remote기준으로 변경하고, pull 받으면 잘됨.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.