Category Archives: development

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 받으면 잘됨.

javascript Object 내 key 존재여부 체크

{} 오브젝트 안에 특정키가 존재하는지 체크하려면??

Object.keys()로 keyset을 추출해서 순회하면서 key name이 일치하는게 있는지 체크하려고 했으나.. 찾아보니 Object.hasOwnProperty를 제공하고 있어서, 바로 ObjectName.hasOwnProperty(key name)을 던져서 존재여부를 확인할 수 있었다.

다만 ESLint를 사용하는데 콘솔에 다음과 같은 메시지가 나온다.

Do not access Object.prototype method ‘hasOwnProperty’ from target object.

찾아보니 Object.prototype의 builtin 제공 메서드를 바로 사용하지 않도록 하는 규칙 때문이라고 하여 , 다음과 같이 사용하면 된다.

// 사용금지
customObject.hasOwnProperty('keyName')

// 권장
Object.prototype.hasOwnProperty.call(customObject, 'keyName')

참고 : https://stackoverflow.com/questions/39282873/object-hasownproperty-yields-the-eslint-no-prototype-builtins-error-how-to