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

2022. 2. 20. 16:00·Git & GitHub/오류해결

 

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
'Git & GitHub/오류해결' 카테고리의 다른 글
  • [오류해결][Git] merge Conflict 해결
  • [오류해결] fatal: The current branch master has no upstream branch.To push the current branch and set the remote as upstream
  • [Git] Please enter a commit message to explain why this merge is necessary, especially if it merges an updated upstream into a topic branch
  • git push 오류가 생길 때 (부제: error: failed to push some refs to)
gakko
gakko
좌충우돌 개발기
  • gakko
    MYVELOP 마이벨롭
    gakko
  • 전체
    오늘
    어제
    • 분류 전체보기 (203)
      • Spring (23)
        • Spring (10)
        • Spring Boot (7)
        • Spring Security (1)
        • Hibernate (4)
      • Test (3)
      • 끄적끄적 (6)
      • 활동 (35)
        • 부스트캠프 (23)
        • 동아리 (3)
        • 컨퍼런스 (3)
        • 글또 (5)
        • 오픈소스 컨트리뷰션 (1)
      • 디자인패턴 (0)
      • Git & GitHub (22)
        • Git (13)
        • Github Actions (1)
        • 오류해결 (5)
        • 기타(마크다운 등) (3)
      • 리눅스 (6)
        • 기초 (6)
        • 리눅스 서버 구축하기 (0)
      • Infra (2)
        • Docker (1)
        • Elastic Search (0)
        • Jenkins (1)
        • AWS (1)
      • MySQL (7)
        • 기초 (6)
        • Real MySQL (1)
      • 후기 (3)
        • Udemy 리뷰 (3)
      • CS (26)
        • 웹 기본지식 (0)
        • 자료구조 (13)
        • 운영체제 OS (12)
        • 데이터베이스 (1)
        • 시스템 프로그래밍 (0)
        • 기타 (0)
      • Tools (1)
        • 이클립스 (1)
        • IntelliJ (0)
      • 프로젝트 (1)
        • 모여모여(부스트캠프) (1)
      • JAVA (32)
        • Maven (6)
        • 오류해결 (11)
        • 자바 클래스&메소드 (1)
        • JSP & Servlet (12)
      • Javascript (5)
        • 기초 (3)
        • React (2)
      • Python (28)
        • 파이썬 함수 (9)
        • 알고리즘 문제풀이 (16)
        • 데이터 사이언스 (2)
        • 웹 크롤링 (1)
      • 단순정보전달글 저장소 (0)
  • 블로그 메뉴

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

    • 우진님
  • 공지사항

  • 인기 글

  • 태그

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

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

티스토리툴바