목차
1. `.gitmodules` 파일에서 에러가 나는 디렉토리의 submodule의 설정을 지워줍니다.
태그
#ERROR
#GIT
#SUBMODULE
[Git Error] is found locally with remote(s)
2024년 2월 19일 15:16

1️⃣ 에러 원인
git submodule add <git link> <dir>
위와 같은 명령어로 git submodule을 설정하려고 했을 때 아래와 같은 에러 메시지가 떴습니다.
fatal: A git directory for '<dir>' is found locally with remote(s):
origin <git link>
If you want to reuse this local git directory instead of cloning again from
<git link>
use the '--force' option. If the local git directory is not the correct repo
or you are unsure what this means choose another name with the '--name' option.
위의 에러가 나타나면 몇 가지를 삭제해주어야 정상적으로 추가가 됩니다.
2️⃣ 해결 방법
.gitmodules
파일에서 에러가 나는 디렉토리의 submodule의 설정을 지워줍니다.
1. [submodule "<dir>"]
path = <dir>
url = https://<git url>.git
.git/config
을 열어 첫 번 째와 같은 submodule 설정을 지워줍니다.
2. [submodule "<dir>"]
url = https://<git url>.git
.git/modules
하위에 있는 submodule 폴더를 지워줍니다.
3. 마지막으로 rm -rf .git/modules/<dir>
이렇게 다 삭제를 한 뒤에 다시 추가하면 정상적으로 서브모듈 설정이 됩니다!
감사합니다