문제 상황
평소처럼 git으로 commit을 하거나, stash로 임시저장후 branch를 변경하려고 했으나, 다음과 같은 에러가 발생하였다.
fatal: cannot lock ref 'HEAD' : Unable to create '프로젝트 경로/,git/HEAD.lock':File exists.
Another git process seems to be running in this repository, e.g.
an editor opened by 'git commit'. Please make sure all processes
are terminated then try again. If it still fails, a git process
may have crashed in this repository earlier:
remove the file manally to continue.
원인
위 오류 메시지는 Git이 현재 작업 중인 리포지토리에 .git/HEAD.lock 파일을 생성하려고 시도했으나, 이미 해당 파일이 존재하기 때문에 발생한다. 이 오류는 일반적으로 다음과 같은 이유로 발생할 수 있다:
- 동시에 여러 Git 프로세스 실행: Git 명령어를 동시에 여러 개 실행할 경우, 잠금 파일(.lock)이 충돌할 수 있습니다.
- 이전 Git 프로세스의 비정상 종료: 이전에 실행된 Git 명령어가 비정상적으로 종료되어 잠금 파일이 남아 있을 수 있습니다.
- 편집기에서 Git 커밋 메시지 작성 중: git commit 명령어를 실행한 후 커밋 메시지를 작성하기 위해 텍스트 편집기가 열려 있는 경우.
해결방안
아래의 명령어로 프로젝트 루트경로(.git이 위치한) 충돌난 lock 파일을 제거
rm -f .git/HEAD.lock // index.lock으로 에러가 떴을시 index.lock
.git 폴더에 해당 lock파일이 있는지 확인을 해보는 것을 추천한다.
(명령어를 입력하지 않고 .git 폴더 내부에서 직접 lock파일을 제거하는 것도 좋을 것 같다.)
참고자료
https://codingdodo.tistory.com/41
[오류대처] Another git process seems to be running in this repository, e.g. an editor opened by 'git commit'. Please make su
Another git process seems to be running in this repository, e.g. an editor opened by 'git commit'. Please make sure all processes are terminated then try again. If it still fails, a git process may have crashed in this repository earlier: remove the file m
codingdodo.tistory.com
https://joycestudios.tistory.com/98
[Git 에러] Another git process seems to be running in this repository(갑자기 잘 사용하던 Git이 안될 때)
[이슈 내용] Git을 사용하다보면 아래와 같이 에러와 함께 Commit 및 Push가 안되는 경우가 있습니다. 현재 다른 프로세스에서 git 프로세스가 동작하고 있어서 index.lock 파일에 의해서 뭔가 락이 걸린
joycestudios.tistory.com
문제 상황
평소처럼 git으로 commit을 하거나, stash로 임시저장후 branch를 변경하려고 했으나, 다음과 같은 에러가 발생하였다.
fatal: cannot lock ref 'HEAD' : Unable to create '프로젝트 경로/,git/HEAD.lock':File exists.
Another git process seems to be running in this repository, e.g.
an editor opened by 'git commit'. Please make sure all processes
are terminated then try again. If it still fails, a git process
may have crashed in this repository earlier:
remove the file manally to continue.
원인
위 오류 메시지는 Git이 현재 작업 중인 리포지토리에 .git/HEAD.lock 파일을 생성하려고 시도했으나, 이미 해당 파일이 존재하기 때문에 발생한다. 이 오류는 일반적으로 다음과 같은 이유로 발생할 수 있다:
- 동시에 여러 Git 프로세스 실행: Git 명령어를 동시에 여러 개 실행할 경우, 잠금 파일(.lock)이 충돌할 수 있습니다.
- 이전 Git 프로세스의 비정상 종료: 이전에 실행된 Git 명령어가 비정상적으로 종료되어 잠금 파일이 남아 있을 수 있습니다.
- 편집기에서 Git 커밋 메시지 작성 중: git commit 명령어를 실행한 후 커밋 메시지를 작성하기 위해 텍스트 편집기가 열려 있는 경우.
해결방안
아래의 명령어로 프로젝트 루트경로(.git이 위치한) 충돌난 lock 파일을 제거
rm -f .git/HEAD.lock // index.lock으로 에러가 떴을시 index.lock
.git 폴더에 해당 lock파일이 있는지 확인을 해보는 것을 추천한다.
(명령어를 입력하지 않고 .git 폴더 내부에서 직접 lock파일을 제거하는 것도 좋을 것 같다.)
참고자료
https://codingdodo.tistory.com/41
[오류대처] Another git process seems to be running in this repository, e.g. an editor opened by 'git commit'. Please make su
Another git process seems to be running in this repository, e.g. an editor opened by 'git commit'. Please make sure all processes are terminated then try again. If it still fails, a git process may have crashed in this repository earlier: remove the file m
codingdodo.tistory.com
https://joycestudios.tistory.com/98
[Git 에러] Another git process seems to be running in this repository(갑자기 잘 사용하던 Git이 안될 때)
[이슈 내용] Git을 사용하다보면 아래와 같이 에러와 함께 Commit 및 Push가 안되는 경우가 있습니다. 현재 다른 프로세스에서 git 프로세스가 동작하고 있어서 index.lock 파일에 의해서 뭔가 락이 걸린
joycestudios.tistory.com