๐Ÿ“š Computer Science/Git

[git] fork ํ•œ ์ €์žฅ์†Œ์™€ fetch upstream ์œผ๋กœ ์ตœ์‹ ํ™”ํ•ด์ฃผ๊ธฐ

ibelieveinme 2021. 10. 17. 11:15
728x90

Forkํ•œ ์ž์‹ ์˜ ๋กœ์ปฌ ์ €์žฅ์†Œ์— remote๋กœ ์›๋ž˜ ์ €์žฅ์†Œ๋ฅผ ๋“ฑ๋กํ•˜๊ณ  ์ตœ์‹ ํ™”ํ•ด์ฃผ๋ฉด ๋œ๋‹ค.

 

 

1) ๋“ฑ๋กํ•˜๊ธฐ ์ „์— ํ˜„์žฌ ์›๊ฒฉ ์ €์žฅ์†Œ๊ฐ€ ๋ฌด์—‡์ด ์žˆ๋Š”์ง€ ํ™•์ธํ•ด๋ณด์ž

$ git remote -v
origin  https://github.com/LeeYunSung/beakJoonCodePlus (fetch)
origin  https://github.com/LeeYunSung/beakJoonCodePlus (push)

ํ˜„์žฌ๋Š” ๋‚ด ์›๊ฒฉ ์ €์žฅ์†Œ๋งŒ ๋“ฑ๋ก๋˜์–ด ์žˆ๋Š” ๊ฒƒ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค.

 

 

2) ์›๊ฒฉ ์ €์žฅ์†Œ์— “upstream”์ด๋ž€ ์ด๋ฆ„์„ ์ฃผ๊ณ  ์›๋ž˜ ์†Œ์Šค ์ €์žฅ์†Œ๋ฅผ ์ถ”๊ฐ€ํ•œ๋‹ค.

$ git remote add upstream https://github.com/suengwone/beakJoonCodePlus.git

 

3) ๋‹ค์‹œ ๋“ฑ๋ก๋œ ์›๊ฒฉ ์ €์žฅ์†Œ๋ฅผ ํ™•์ธํ•ด ๋ณด๋ฉด ์•„๋ž˜์™€ ๊ฐ™์ด forkํ•œ ์ €์žฅ์†Œ๊ฐ€ ์ถ”๊ฐ€๋œ ๊ฒƒ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค.

$ git remote -v

origin  https://github.com/LeeYunSung/beakJoonCodePlus (fetch)
origin  https://github.com/LeeYunSung/beakJoonCodePlus (push)
upstream        https://github.com/suengwone/beakJoonCodePlus.git (fetch)
upstream        https://github.com/suengwone/beakJoonCodePlus.git (push)โ€‹

 

4) ์ถ”๊ฐ€ํ•œ “upstream” ์ €์žฅ์†Œ๋ฅผ “fetch”ํ•œ๋‹ค.

์ด ๋•Œ, fetch์™€ pull์˜ ์ฐจ์ด๋Š” ๊ฐ€์ ธ์™€์„œ ๋จธ์ง€๊นŒ์ง€ ์ž๋™์„ ํ•ด์ฃผ๋Š๋ƒ ์•ˆ ํ•ด์ฃผ๋Š๋ƒ์˜ ์ฐจ์ด์ด๊ณ  “fetch”๋Š” ๋จธ์ง€๋Š” ์•ˆ ํ•ด์ค€๋‹ค.

$ git fetch upstream

From https://github.com/suengwone/beakJoonCodePlus
 * [new branch]      dataStructure -> upstream/dataStructure
 * [new branch]      main          -> upstream/main
 * [new branch]      math          -> upstream/math
 * [new branch]      sorting       -> upstream/sorting
 * [new branch]      strings       -> upstream/strings

 

5) ์ด์ œ ์›๋ž˜ ์ž์‹ ์˜ ๋กœ์ปฌ ์ €์žฅ์†Œ์˜ master๋ฅผ checkoutํ•œ๋‹ค.

$ git checkout master
Switched to branch 'master'

 

5) fetch ํ•ด๋‘์—ˆ๋˜ “upstream/master”๋ฅผ ์ฒดํฌ์•„์›ƒํ–ˆ๋˜ “master” ๋ธŒ๋žœ์น˜๋กœ mergeํ•œ๋‹ค.

$ git merge upstream/master

 

6) ๋จธ์ง€ํ•˜๊ณ  Github์—๋„ ๋ฐ˜์˜ํ•˜๋ ค๋ฉด git push ํ•˜๋ฉด ๋œ๋‹ค.

 

728x90