[Git] Submodule

Inhye Jeong·2020년 8월 23일
0

Git

목록 보기
3/7

깃 서브모듈

git에서 여러 repository에서 공용으로 사용해야하는 로직을 모아둔 모듈을 만들고 각 레포에서 사용할 때, git submodule을 사용한다.

1) module을 가져올 directory로 이동한다.

> checkout MAIN_REPO
> cd src/model

2) git submodule add

submodule을 추가하는 명령어. [path]는 옵션.

$ git submodule add <repository> [path]

명령어를 실행하면 아래와 같이 나온다.

➜  scan.games.front git:(IH) ✗ git submodule add https://github.com/react5f7pm/scan.games.model.git
Cloning into '/Users/inhye/development/git-repository/scan.games.front/scan.games.model'...
remote: Enumerating objects: 12, done.
remote: Counting objects: 100% (12/12), done.
remote: Compressing objects: 100% (9/9), done.
remote: Total 12 (delta 2), reused 8 (delta 1), pack-reused 0
Unpacking objects: 100% (12/12), done.

gitmodules 파일과 추가한 submodule directory가 추가된다.

src git:(IH) ✗ git status
On branch IH
Your branch is up to date with 'origin/IH'.
Untracked files:
  (use "git add <file>..." to include in what will be committed)

	../.gitmodules
	scan.games.model/

reference

profile
Frontend Engineer in @KakaoStyle

0개의 댓글