μλΈλͺ¨λ(Git Submodule)μ νλμ Git 리ν¬μ§ν 리 μμ λ€λ₯Έ Git 리ν¬μ§ν 리λ₯Ό ν¬ν¨ ν΄μ μ¬μ©νλ λ°©μμ λλ€. 볡μ‘ν νλ‘μ νΈλ₯Ό λΆλ¦¬νμ¬ κ΄λ¦¬ν λ μ μ©νμ§λ§, μΌλ°μ μΈ νλ‘μ νΈμμλ κ΄λ¦¬κ° κΉλ€λ‘μ΅λλ€.
my-project/
βββ .gitmodules
βββ main-code/
βββ shared-lib/ β μΈλΆ 리ν¬μ§ν 리 μ°κ²° (μλΈλͺ¨λ)
μλ₯Ό λ€μ΄, shared-lib
μ΄ λ³λ GitHub 리ν¬μ΄κ³ my-project
μμ ν¬ν¨ν κ²½μ°μ
λλ€.
git submodule add <https://github.com/μ¬μ©μλͺ
/λ ν¬.git> shared-lib
.gitmodules
νμΌμ μλ μμ±νκ³ ,shared-lib
λλ ν 리λ₯Ό μΈλΆ 리ν¬λ‘ μ°κ²°ν©λλ€.git clone <https://github.com/λ΄λ ν¬.git>
cd λ΄λ ν¬
git submodule update --init --recursive
λλ ν μ€λ‘:
git clone --recurse-submodules <https://github.com/λ΄λ ν¬.git>
μλΈλͺ¨λ λ΄λΆλ‘ λ€μ΄κ°μ μμ ν ν, 루νΈμμ λ€μ λͺ λ ΉμΌλ‘ μ λ°μ΄νΈ λ°μ:
cd shared-lib
git checkout main
git pull origin main
cd ..
git add shared-lib
git commit -m "chore: update shared-lib submodule"