[오류해결] fatal: Unable to create '~~/.git/index.lock': File exists.

2022. 2. 20. 16:00·레거시모음/오류해결

 

git에 이유 모를 에러가 발생해서 강제종료되었다. 그래서 다시 git을 실행하여 git add 명령어를 사용했는데 아래와 같은 에러가 발생할 때가 있을 것이다.

$ git add .
fatal: Unable to create '디렉토리/.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 디렉토리에 index.lock 파일이 존재하기 때문에 git add 를 할 수 없다는 말이다.

해결 방법은 간단하다. 해당 파일을 삭제하면 된다. 이 파일을 삭제할 수 있는 2가지 방법을 알려주겠다.

 

 

 

1. 폴더에서 직접 파일 삭제하기


해당 디렉토리 폴더에 .git 폴더로 들어가서 index.lock을 삭제하면 된다.

 

 

 

2. 명령어로 삭제하기


아마 해당 디렉토리에는 이미 접속해있을 것이므로 아래 명령어를 쳐주면 바로 해결될 것이다.

 

$ rm -f .git/index.lock
'레거시모음/오류해결' 카테고리의 다른 글
  • [SpringBoot][오류해결] The dependencies of some of the beans in the application context form a cycle
  • [Spring Boot][오류해결] Modifying queries can only use void or int/Integer as return type
  • [Spring Boot][오류해결] Executing an update/delete query
  • [오류해결][Git] merge Conflict 해결
gakko
gakko
좌충우돌 개발기
  • gakko
    MYVELOP 마이벨롭
    gakko
  • 전체
    오늘
    어제
    • 분류 전체보기 (210) N
      • 끄적끄적 (6)
      • Spring (19) N
      • Java (3)
      • Redis (2) N
      • Test (3)
      • 대외활동 (36)
        • 부스트캠프 (23)
        • IT커뮤니티 (5)
        • 글또 (5)
        • 컨퍼런스 (3)
      • Infra (5)
        • Docker (1)
        • Jenkins (1)
        • AWS (1)
      • CS (26)
        • 자료구조 (13)
        • 운영체제 OS (12)
        • 데이터베이스 (1)
      • MySQL (7)
      • Git & GitHub (16)
        • Git (12)
        • Github Actions (1)
        • 기타(마크다운 등) (3)
      • 프로젝트 (2)
      • 리눅스 (6)
        • 기초 (6)
        • 리눅스 서버 구축하기 (0)
      • 후기 (3)
        • Udemy 리뷰 (3)
      • Python (12)
      • 레거시모음 (64)
        • 스프링 (11)
        • 자바 클래스&메소드 (1)
        • 오류해결 (18)
        • JSP & Servlet (12)
        • 자바스크립트 기초 (3)
        • React (2)
        • 이클립스 (1)
        • 알고리즘 문제풀이 (16)
      • 디자인패턴 (0)
  • 블로그 메뉴

    • 홈
    • 태그
    • 방명록
  • 링크

    • 우진님
  • 공지사항

  • 인기 글

  • 태그

    웹개발
    파이썬
    java
    자바스크립트
    Spring
    스프링부트
    부스트캠프 멤버십
    Python
    자바
    os
    jsp
    운영체제
    GitHub
    부스트캠프
    오류해결
    MySQL
    스프링
    알고리즘
    Git
    부스트캠프 7기
  • 최근 댓글

  • hELLO· Designed By정상우.v4.10.0
gakko
[오류해결] fatal: Unable to create '~~/.git/index.lock': File exists.
상단으로

티스토리툴바