GitNotes.9-5.md
본 문서는 Git Notes for Professionals (라이센스:CC-BY-SA) 를 한글로 번역한 문서입니다. 번역상 오류가 있을 수 있으므로 정확한 내용은 원본 문서를 참고하세요.

Section 9.5: submodule 위치 변경하기

Version > 1.8

다음과 같이 수행한다:

$ git mv old/path/to/module new/path/to/module

Version ≤ 1.8

  1. .gitmodules 파일을 수정하여 submodule 의 경로를 적절하게 변경한 후, git add .gitmodules 명령어를 통해 index 에 추가한다.

  2. 필요한 경우, submodule 이 위치할 새로운 경로의 부모 디렉토리를 생성한다 (mkdir -p new/path/to).

  3. 기존 디렉토리 내의 모든 내용물들을 새로운 디렉토리로 이동시킨다 (mv -vi old/path/to/module new/path/to/module).

  4. Git 이 새로운 디렉토리를 추적하도록 설정한다 (git add new/path/to).

  5. 기존 디렉토리를 git rm --cached old/path/to/module 명령어를 이용해 삭제한다.

  6. .git/modules/old/path/to/module 디렉토리를 모든 내용물들과 함께 .git/modules/new/path/to/module 로 이동시킨다.

  7. .git/modules/new/path/to/config 파일을 수정하여, 파일 내의 worktree 항목이 새로운 위치를 정확히 가리키고 있는지를 확인한다. 이 예제에서는 worktree = ../../../../../new/path/to/module 이 되어야 할 것이다. 일반적으로 해당 모듈 위치의 깊이에서 두개의 .. 가 추가될 것이다. new/path/to/module/.git 파일도 수정하여, 메인 프로젝트의 새로운 .git 폴더 위치를 정확히 참조하도록 한다. 이 예제에서는 gitdir: ../../../.git/modules/new/path/to/module 이 되어야 할 것이다. 이 시점에서 git status 명령어의 결과는 다음과 같을 것이다:

    # On branch master # Changes to be committed: # (use "git reset HEAD <file>..." to unstage) # # modified: .gitmodules # renamed: old/path/to/module -> new/path/to/module #
  8. 마지막으로, 변경 사항을 커밋한다.

위 예제는 Axel BeckertStack Overflow 예제에서 발췌되었다.

[출처] https://books.goalkicker.com/GitBook/ (CC BY-SA)

반응형

+ Recent posts