Github λ±μμ git μ ν΅ν΄ μ½λλ₯Ό κ΄λ¦¬νλ€ λ³΄λ©΄ μ¬λ¬ repo μ μ€λ³΅λλ μ½λκ° λ°μν μ μλ€.
μ΄λ° repo κ° μ½λ μ€λ³΅μ νΌνκΈ° μν΄ νΉμ repo μμ λ€λ₯Έ repo λ₯Ό μ°κ²°ν΄μ μ¬μ©νλ©΄ μ€λ³΅μ νΌν μ μλλ°, git subtree λ₯Ό νμ©νλ©΄ κ°λ₯νλ€. (리λ μ€μμμ symbloic link μ λΉμ·νλ€κ³ ν΄μΌν κΉ?)
- λ©μΈ repo : mysite
- μλΈ repo : utils (μ°κ²°ν repo)
λ©μΈ repo μ μ΅μμ ν΄λμμ μλ λͺ λ Ήμ μμλλ‘ μ€ν
1. remote μ μ°κ²°ν repo λ±λ‘
$ git remote add [remote μ΄λ¦] [μ°κ²°ν repo μ£Όμ]
$ git remote add utils https://github.com/okojj/utils.git
2. λ±λ‘λ remote νμΈ
$ git remote -v
origin https://github.com:okojj/mysite.git (fetch)
origin https://github.com/okojj/mysite.git (push)
utils https://github.com/okojj/utils.git (fetch)
utils https://github.com/okojj/utils.git (push)
3. git subtree λͺ λ ΉμΌλ‘ μ°κ²° λ±λ‘
$ git subtree add --prefix=[μμ±ν ν΄λλͺ ] [μ°κ²°ν repo μ΄λ¦] [μ°κ²°ν repoμ branch]
$ git subtree add --prefix=utils utils main
git fetch utils main
remote: Enumerating objects: 11, done.
remote: Counting objects: 100% (11/11), done.
remote: Compressing objects: 100% (8/8), done.
remote: Total 11 (delta 1), reused 6 (delta 0), pack-reused 0
Unpacking objects: 100% (11/11), 1.77 KiB | 362.00 KiB/s, done.
From github.com:okojj/utils
* branch main -> FETCH_HEAD
* [new branch] main -> utils/main
Added dir 'utils'
λ‘컬μ μμ±λ utils ν΄λ νμΈ
4. git push λ‘ remote μ λ±λ‘
$ git push
Enumerating objects: 14, done.
Counting objects: 100% (14/14), done.
Delta compression using up to 2 threads
Compressing objects: 100% (10/10), done.
Writing objects: 100% (13/13), 2.19 KiB | 2.19 MiB/s, done.
Total 13 (delta 0), reused 0 (delta 0), pack-reused 0
To github.com:okojj/mysite.git
6f7327c..b79940f main -> main
5. subtree ν΄λ μ격μμ λ΄λ €λ°κΈ° (pull)
subtree λ‘ μΆκ°ν ν΄λμ μ λ°μ΄νΈκ° μμ κ²½μ° λ°μνλ λ°©λ²
$ git subtree pull --prefix=utils utils main
6. subtree ν΄λλ₯Ό μ격μ λ°μνκΈ° (push)
subtree ν΄λ λ΄μ λ³κ²½μ¬νμ λν΄ remote μ λ°μνλ κ²½μ°
$ git subtree push --prefix=utils utils main
728x90