git subtree๋Š” Git์—์„œ **ํ•˜์œ„ ๋ฆฌํฌ์ง€ํ† ๋ฆฌ(sub-repository)**๋ฅผ ๊ด€๋ฆฌํ•˜๊ธฐ ์œ„ํ•œ ๋ฉ”์ปค๋‹ˆ์ฆ˜์ž…๋‹ˆ๋‹ค. ์ด๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด ํ•œ ๋ฆฌํฌ์ง€ํ† ๋ฆฌ์˜ ๋””๋ ‰ํ† ๋ฆฌ ๋‚ด์— ๋˜ ๋‹ค๋ฅธ ๋ฆฌํฌ์ง€ํ† ๋ฆฌ์˜ ๋‚ด์šฉ์„ ํฌํ•จ์‹œํ‚ฌ ์ˆ˜ ์žˆ์œผ๋ฉฐ, ๊ฐ ๋ฆฌํฌ์ง€ํ† ๋ฆฌ๋ฅผ ๋…๋ฆฝ์ ์œผ๋กœ ๊ด€๋ฆฌํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. git submodule๊ณผ ๋น„๊ต๋˜๋Š” ๊ธฐ๋Šฅ์œผ๋กœ, ์˜์กด์„ฑ ๊ด€๋ฆฌ๋ฅผ ๊ฐ„๋‹จํ•˜๊ฒŒ ํ•˜๋ ค๋Š” ๋ชฉ์ ์œผ๋กœ ์ž์ฃผ ์‚ฌ์šฉ๋ฉ๋‹ˆ๋‹ค.


Git Subtree์˜ ํ•ต์‹ฌ ๊ฐœ๋…

  1. ๋…๋ฆฝ์ ์ธ ๋ฆฌํฌ์ง€ํ† ๋ฆฌ ํฌํ•จ
  2. ์™„์ „ํ•œ ์ปค๋ฐ‹ ๋‚ด์—ญ ๋ณด์กด
  3. ๋ณ‘ํ•ฉ๊ณผ ๋ถ„๋ฆฌ๊ฐ€ ๊ฐ„๋‹จ

Git Subtree์˜ ์ฃผ์š” ๋ช…๋ น์–ด

1. Subtree ์ถ”๊ฐ€

๋‹ค๋ฅธ ๋ฆฌํฌ์ง€ํ† ๋ฆฌ๋ฅผ ํ˜„์žฌ ๋ฆฌํฌ์ง€ํ† ๋ฆฌ์— ์ถ”๊ฐ€ํ•ฉ๋‹ˆ๋‹ค.

git subtree add --prefix=<directory> <repository-url> <branch> [--squash]

2. Subtree ์—…๋ฐ์ดํŠธ

์„œ๋ธŒ ๋ฆฌํฌ์ง€ํ† ๋ฆฌ์˜ ๋‚ด์šฉ์„ ์ตœ์‹  ์ƒํƒœ๋กœ ์—…๋ฐ์ดํŠธํ•ฉ๋‹ˆ๋‹ค.

git subtree pull --prefix=<directory> <repository-url> <branch> [--squash]

3. Subtree ํ‘ธ์‹œ