ํ์ ํธ๋ฆฌ ๋ณํฉ ์ ๋ณด
์ผ๋ฐ์ ์ผ๋ก ํ์ ํธ๋ฆฌ ๋ณํฉ์ ๋ฆฌํฌ์งํ ๋ฆฌ ๋ด์ ๋ฆฌํฌ์งํ ๋ฆฌ๋ฅผ ํฌํจํ๋ ๋ฐ ์ฌ์ฉ๋ฉ๋๋ค. โํ์ ๋ฆฌํฌ์งํ ๋ฆฌโ๋ ์ฃผ ๋ฆฌํฌ์งํ ๋ฆฌ์ ํด๋์ ์ ์ฅ๋ฉ๋๋ค.
ํ์ ํธ๋ฆฌ ๋ณํฉ์ ์ค๋ช ํ๋ ๊ฐ์ฅ ์ข์ ๋ฐฉ๋ฒ์ ์๋ฅผ ๋ค์ด ๋ณด์ฌ ์ฃผ๋ ๊ฒ์ ๋๋ค. ๋ค์์ ์ํํฉ๋๋ค.
- ํ๋ก์ ํธ๋ฅผ ๋ํ๋ด๋
test
๋ผ๋ ์ด๋ฆ์ ๋น ๋ฆฌํฌ์งํ ๋ฆฌ๋ฅผ ํธ์ถํฉ๋๋ค. - ๋ค๋ฅธ ๋ฆฌํฌ์งํ ๋ฆฌ๋ฅผ
Spoon-Knife
๋ผ๋ ํ์ ํธ๋ฆฌ๋ก ๋ณํฉํฉ๋๋ค. test
ํ๋ก์ ํธ๋ ๋์ผํ ๋ฆฌํฌ์งํ ๋ฆฌ์ ์ผ๋ถ์ธ ๊ฒ์ฒ๋ผ ํ์ ํ๋ก์ ํธ๋ฅผ ์ฌ์ฉํฉ๋๋ค.- ์
๋ฐ์ดํธ๋ฅผ
Spoon-Knife
์์test
ํ๋ก์ ํธ๋ก ํ์นํฉ๋๋ค.
ํ์ ํธ๋ฆฌ ๋ณํฉ์ ๋ํ ๋น ๋ฆฌํฌ์งํ ๋ฆฌ ์ค์
-
ํฐ๋ฏธ๋ํฐ๋ฏธ๋Git Bash๋ฅผ ์ฝ๋๋ค.
-
์ ๋๋ ํฐ๋ฆฌ๋ฅผ ๋ง๋ค๊ณ ํด๋น ๋๋ ํฐ๋ฆฌ๋ก ์ด๋ํฉ๋๋ค.
mkdir test cd test
-
์ Git ๋ฆฌํฌ์งํ ๋ฆฌ๋ฅผ ์ด๊ธฐํํฉ๋๋ค.
$ git init > Initialized empty Git repository in /Users/octocat/tmp/test/.git/
-
์ ํ์ผ์ ๋ง๋ค๊ณ ์ปค๋ฐํฉ๋๋ค.
$ touch .gitignore $ git add .gitignore $ git commit -m "initial commit" > [main (root-commit) 3146c2a] initial commit > 0 files changed, 0 insertions(+), 0 deletions(-) > create mode 100644 .gitignore
ํ์ ํธ๋ฆฌ๋ก ์ ๋ฆฌํฌ์งํ ๋ฆฌ ์ถ๊ฐ
-
๊ด์ฌ ์๋ ๋ณ๋์ ํ๋ก์ ํธ๋ฅผ ๊ฐ๋ฆฌํค๋ ์ ์๊ฒฉ URL์ ์ถ๊ฐํฉ๋๋ค.
$ git remote add -f spoon-knife https://github.com/octocat/Spoon-Knife.git > Updating spoon-knife > warning: no common commits > remote: Counting objects: 1732, done. > remote: Compressing objects: 100% (750/750), done. > remote: Total 1732 (delta 1086), reused 1558 (delta 967) > Receiving objects: 100% (1732/1732), 528.19 KiB | 621 KiB/s, done. > Resolving deltas: 100% (1086/1086), done. > From https://github.com/octocat/Spoon-Knife > * [new branch] main -> Spoon-Knife/main
-
Spoon-Knife
ํ๋ก์ ํธ๋ฅผ ๋ก์ปฌ Git ํ๋ก์ ํธ์ ๋ณํฉํฉ๋๋ค. ์ด๋ ๊ฒ ํ๋ฉด ํ์ผ์ด ๋ก์ปฌ์์ ๋ณ๊ฒฝ๋์ง๋ ์์ง๋ง Git์ ๋ค์ ๋จ๊ณ๋ฅผ ์ค๋นํฉ๋๋ค.Git 2.9 ์ด์์ ์ฌ์ฉํ๋ ๊ฒฝ์ฐ:
$ git merge -s ours --no-commit --allow-unrelated-histories spoon-knife/main > Automatic merge went well; stopped before committing as requested
Git 2.8 ์ดํ๋ฅผ ์ฌ์ฉํ๋ ๊ฒฝ์ฐ:
$ git merge -s ours --no-commit spoon-knife/main > Automatic merge went well; stopped before committing as requested
-
spoon-knife๋ผ๋ ์ ๋๋ ํฐ๋ฆฌ๋ฅผ ๋ง๋ค๊ณ ํ๋ก์ ํธ์ Git ๊ธฐ๋ก์
Spoon-Knife
ํ๋ก์ ํธ์ ๋ณต์ฌํฉ๋๋ค.$ git read-tree --prefix=spoon-knife/ -u spoon-knife/main > fatal: refusing to merge unrelated histories
-
๋ณ๊ฒฝ ๋ด์ฉ์ ์ปค๋ฐํ์ฌ ์์ ํ๊ฒ ์ ์งํฉ๋๋ค.
$ git commit -m "Subtree merged in spoon-knife" > [main fe0ca25] Subtree merged in spoon-knife
ํ์ ํ๋ก์ ํธ๋ฅผ ํ๋๋ง ์ถ๊ฐํ๋๋ผ๋ ์ฌ๋ฌ ํ์ ํ๋ก์ ํธ๋ฅผ Git ๋ฆฌํฌ์งํ ๋ฆฌ์ ํตํฉํ ์ ์์ต๋๋ค.
ํ
๋์ค์ ๋ฆฌํฌ์งํ ๋ฆฌ์ ์ ๋ณต์ ๋ณธ์ ๋ง๋๋ ๊ฒฝ์ฐ ์ถ๊ฐํ ์๊ฒฉ์ด ์์ฑ๋์ง๋ ์์ต๋๋ค. git remote add
๋ช
๋ น์ ์ฌ์ฉํ์ฌ ๋ค์ ์ถ๊ฐํด์ผ ํฉ๋๋ค.
์ ๋ฐ์ดํธ ๋ฐ ๋ณ๊ฒฝ ๋ด์ฉ๊ณผ ๋๊ธฐํ
ํ์ ํ๋ก์ ํธ๊ฐ ์ถ๊ฐ๋๋ฉด ์ ์คํธ๋ฆผ ๋ณ๊ฒฝ ๋ด์ฉ๊ณผ ์๋์ผ๋ก ๋๊ธฐํ๋์ง ์์ต๋๋ค. ๋ค์ ๋ช ๋ น์ ์ฌ์ฉํ์ฌ ํ์ ํ๋ก์ ํธ๋ฅผ ์ ๋ฐ์ดํธํด์ผ ํฉ๋๋ค.
git pull -s subtree REMOTE-NAME BRANCH-NAME
์์ ์์์๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค.
git pull -s subtree spoon-knife main