⚠️[Git] fatal: Unable to create '~~/.git/index.lock':File exists.

dev_itzel_02✨·2024년 8월 26일

⚠️Trouble Shooting

목록 보기
4/10
post-thumbnail

❓Situation

파일을 작성하고 터미널에 'git add .' 명령어를 작성하였는데, 아래와 같은 오류가 발생했다.

fatal: Unable to create 'C:/Users/User/.git/index.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 manually to continue.

살펴보자면,,,
다른 git 프로세스가 동일한 레포지토리에서 실행중이다.
그러니 모든 프로세스들이 모두 종료된 후에 다시 시도해라..~ 는 내용.

.git 디렉토리에 index.lock 파일이 존재하기 때문에 git add를 할 수 없다는 말이다.

index.lock 파일이 뭐냐하면 👉👉 클릭 ..!!

🔧Solution

실행중인 git 프로세스가 없다면 일시적인 오류일 수 있으므로 해당 파일 삭제하면 된다.

sol1) 폴더에서 직접 파일 삭제하기

해당 디렉토리 폴더에 .git 폴더로 들어가서 index.lock 파일 삭제
참고로, .git 폴더는 숨김 폴더이므로 '보기 >> 숨김파일보기' 해야 폴더가 보임

sol2) 명령어로 삭제

해당 디렉토리에 이미 접속해있다면 아래 명령어를 작성

$ rm -f .git/index.lock

🐾References

profile
🐜👣steadiness🐜👣

0개의 댓글