로컬에서 서브모듈을 사용하고 싶은 레포지토리 경로까지 이동

git submodule add {서브모듈로 사용할 레포지토리 url}

❯ git submodule add <https://github.com/depromeet/sulsul-secret.git>
Cloning into '/Users/zeze_home/project_dir/sulsul-BE/src/main/resources/sulsul-secret'...
warning: You appear to have cloned an empty repository.
fatal: You are on a branch yet to be born
Unable to checkout submodule 'src/main/resources/sulsul-secret'

# sulsul-secret 레포가 원격 브랜치와 로컬 브랜치가 연동되지 않아서 파일이 뜨지 않았음
# 깃 오류 해결하니깐 resources/sulsul-secret/파일들 생김

로컬에는 서브모듈이 보이지만 원격 저장소에는 변화 없음

❯ git add .
warning: adding embedded git repository: src/main/resources/sulsul-secret
hint: You've added another git repository inside your current repository.
hint: Clones of the outer repository will not contain the contents of
hint: the embedded repository and will not know how to obtain it.
hint: If you meant to add a submodule, use:
hint:
hint: 	git submodule add <url> src/main/resources/sulsul-secret
hint:
hint: If you added this path by mistake, you can remove it from the
hint: index with:
hint:
hint: 	git rm --cached src/main/resources/sulsul-secret
hint:
hint: See "git help submodule" for more information.

에러 참고문서: https://stackoverflow.com/questions/20929336/git-submodule-add-a-git-directory-is-found-locally-issue

❯ git status
On branch prod
Your branch is up to date with 'origin/prod'.

Changes not staged for commit:
  (use "git add/rm <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
	deleted:    ../../../.gitmodules
	deleted:    config

no changes added to commit (use "git add" and/or "git commit -a")
❯ git rm ../../../.gitmodules
rm '.gitmodules'
❯ git status
On branch prod
Your branch is up to date with 'origin/prod'.

Changes to be committed:
  (use "git restore --staged <file>..." to unstage)
	deleted:    ../../../.gitmodules

Changes not staged for commit:
  (use "git add/rm <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
	deleted:    config

❯ git rm config
rm 'src/main/resources/config'
❯ git status
On branch prod
Your branch is up to date with 'origin/prod'.

Changes to be committed:
  (use "git restore --staged <file>..." to unstage)
	deleted:    ../../../.gitmodules
	deleted:    config

# 요고 하고 git push하고 터미널 다시 키기

기존 서브모듈 삭제하기

# .gitmodule 파일 삭제해도 캐시 남음
❯ rm -rf .git/modules/src/main/resources/config
❯ git rm --cached src/main/resources/config

다시 생성

# config라는 이름의 서브모듈 폴더 생성 
❯ git submodule add <https://github.com/depromeet/sulsul-secret.git> config

.gitmodules