> For the complete documentation index, see [llms.txt](https://teamsmiley.gitbook.io/devops/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://teamsmiley.gitbook.io/devops/git/submodule.md).

# Submodule

## submodule 등록

git에서 다른 git을 하위폴더에 가져와서 같이 사용하는것

```bash
git clone main_repo_url

git submodule add git@github.com:prometheus-operator/kube-prometheus.git
cd kube-prometheus
git checkout tags/v0.8.0
```

## clone

클론을 처음 받을때 submodule까지 받을수 있다.

```
git clone --recursive git@git://github.com/foo/bar.git
```

## 클론을 미리 받은경우

새로 체크아웃 받는경우 submodule은 다운로드 되지 않는다. 따로 관리해야한다.

```bash
git clone git://github.com/foo/bar.git
cd bar
git submodule update --init --recursive
```

## tag를 유지

checkout을 tag로 해두면 이 버전이 유지된다.

## submodule 삭제

```bash
submodule_path=kube-prometheus

git rm --cached ${submodule_path}
```

.gitmodules 에서 원하는 git submodule을 삭제한다.

폴더를 삭제한다.

```bash
rm -rf ${submodule_path}
rm -rf .git/modules/${submodule_path}
```

## 커맨드로만 하는 방법

```bash
submodule_path=kube-prometheus

git submodule deinit -f ${submodule_path}
git rm ${submodule_path}
# Note: submodule_path (no trailing slash)
git rm --cached ${submodule_path}
rm -rf .git/modules/${submodule_path}
```

## todo

subtree와 차이점은 무엇일가?


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://teamsmiley.gitbook.io/devops/git/submodule.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
