git(6) - Fork๐Ÿด & pull request๐Ÿ™


๋ชฉ์ 

A๋ฟ๋งŒ ์•„๋‹ˆ๋ผ B๋„ ๋กœ์ปฌ ์ €์žฅ์†Œ์— ๋ธŒ๋žœ์น˜๋ฅผ ์ƒ์„ฑํ•ด์„œ ๊ฐ™์€ ์›๊ฒฉ ์ €์žฅ์†Œ์— ํ‘ธ์‹œํ•˜๋Š” ๊ฒฝ์šฐ์— ์ถฉ๋Œ์ด ์ผ์–ด๋‚  ์ˆ˜ ์žˆ๊ธฐ๋•Œ๋ฌธ์— pull request๋ฅผ ํ†ตํ•ด ์›๊ฒฉ ์ €์žฅ์†Œ์— ์š”์ฒญํ•˜๊ณ  ์›๊ฒฉ ์ €์žฅ์†Œ์—์„œ merge ํ•˜๋Š”๊ฒƒ

๋˜ํ•œ ์ž์‹ ์ด ์†Œ์œ ํ•˜์ง€ ์•Š๊ณ  ๊ถŒํ•œ์ด ์—†๋Š” ์ž‘์—…์— ๋Œ€ํ•ด ํ˜‘์—… ํ•˜๊ธฐ ์œ„ํ•ด์„œ ์‚ฌ์šฉํ•œ๋‹ค.


์‚ฌ์šฉ ๋ฐฉ๋ฒ•


1. Fork

  • ๊ฐ€์ ธ์˜ค๊ณ ์ž ํ•˜๋Š” ์ €์žฅ์†Œ๋ฅผ ์ž์‹ ์˜ ์ €์žฅ์†Œ๋กœ Forkํ•œ๋‹ค.

git_image


2. ๋‚ด ์ปดํ“จํ„ฐ์˜ ๋กœ์ปฌ์ €์žฅ์†Œ์— ์›๊ฒฉ์ €์žฅ์†Œ๋ฅผ ์ถ”๊ฐ€(clone)

  • Fork๋กœ ์ƒ์„ฑํ•œ ์ €์žฅ์†Œ์—์„œ clone or download ๋ฒ„ํŠผ์„ ๋ˆ„๋ฅด๊ณ  ํ‘œ์‹œ๋˜๋Š” URL์„ ๋ณต์‚ฌํ•œ๋‹ค.
$ git clone {๋ณต์‚ฌํ•œ URL}

/Users/mac - (main) > cd Desktop # Desktop์œผ๋กœ ์ด๋™ ํ›„ ํด๋” ์ƒ์„ฑ
$ git clone https://github.com/kimbap918/pull_folder.git

git_image

mac/Desktop - (main) > cd pull_folder # ํด๋” ์ƒ์„ฑ ํ›„ ์ƒ์„ฑ๋œ ํด๋” ๋‚ด๋กœ ์ด๋™
Desktop/pull_folder - (master) > 


3. branch ์ƒ์„ฑ

  • ๋‚ด ์ปดํ“จํ„ฐ์˜ clone๋œ ์ €์žฅ์†Œ(origin)์—์„œ ์ฝ”๋“œ๋ฅผ ์ˆ˜์ •ํ•˜๊ฑฐ๋‚˜ ์ถ”๊ฐ€ํ•˜๋Š” ์ž‘์—…์€ branch๋ฅผ ๋งŒ๋“ค์–ด์„œ ์ง„ํ–‰ํ•œ๋‹ค.
$ git branch {branch name}
$ git branch example

Desktop/pull_folder - (master) > git branch example


  • ์ƒ์„ฑ ํ›„ ์ด๋™
$ git checkout {branch name}
$ git checkout example

Desktop/pull_folder - (master) > git checkout example
Switched to branch 'example'
Desktop/pull_folder - (example) > # master -> example๋กœ branch๊ฐ€ ์ด๋™๋จ


  • ์ƒ์„ฑ๋œ ํด๋”์˜ ๋ชจ์Šต

git_image


4. ์ˆ˜์ • ์ž‘์—… ํ›„ add, commit, push

  • ์ž‘์—…๋ฌผ์„ ์ถ”๊ฐ€

git_image

Desktop/pull_folder - (example) > git add .
Desktop/pull_folder - (example) > git commit -m "request"
Desktop/pull_folder - (example) > git push origin example
  • ์ž‘์—…์ด ์™„๋ฃŒ๋˜๋ฉด Github Repository(origin)์— add, commit, pushํ•œ๋‹ค.
  • pushํ• ๋•Œ develop ๋ธŒ๋žœ์น˜์˜ ์ˆ˜์ •๋‚ด์—ญ์„ origin์œผ๋กœ ํ‘ธ์‹œํ•œ๋‹ค.


5. pull Request ์ƒ์„ฑ

  • push ์™„๋ฃŒํ›„ ์ž์‹ ์˜ github ์ €์žฅ์†Œ์—์„œ Compare & pull request๋ฒ„ํŠผ์ด ํ™œ์„ฑํ™” ๋˜์–ด์žˆ๋Š”๊ฑธ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค.
  • ๋ฒ„ํŠผ์„ ์„ ํƒํ•ด Pull Request๋ฅผ ์ƒ์„ฑํ•œ๋‹ค.

git_image


  • ๋‚ด์šฉ์„ ์ž‘์„ฑ ํ›„ pull request ๋ฅผ ์ƒ์„ฑ

git_image


6. Merge Pull Request

  • PR์„ ๋ฐ›์€ ๊ด€๋ฆฌ์ž๋Š” ์ฝ”๋“œ ๋ณ€๊ฒฝ๋‚ด์—ญ์„ ํ™˜์ธํ•˜๊ณ  Merge์—ฌ๋ถ€๋ฅผ ๊ฒฐ์ •ํ•˜๊ฒŒ ๋œ๋‹ค.


7. Merge ์ดํ›„ ๋™๊ธฐํ™” ๋ฐ branch ์‚ญ์ œ

  • Merge๊ฐ€ ์™„๋ฃŒ๋˜๋ฉด ๋กœ์ปฌ ์ฝ”๋“œ์™€ ์›๋ณธ์˜ ์ฝ”๋“œ๋ฅผ ๋ณ‘ํ•ฉํ•˜๊ณ  ์ตœ์‹ ์˜ ์ƒํƒœ๋ฅผ ์œ ์ง€ํ•˜๊ฒŒ ์œ„ํ•ด ๋™๊ธฐํ™”ํ•œ๋‹ค.
  • upstream ํ™•์ธ
$ git remote -v  
  • upstream ์ถ”๊ฐ€
$ git remote add upstream
$ git fetch upstream
$ git merge upstream/master
$ git branch -d example
  • ์œ„ ๋ช…๋ น์–ด๋ฅผ ํ†ตํ•ด ๋™๊ธฐํ™”ํ•˜๊ณ , ๋ธŒ๋žœ์น˜๋ฅผ ์‚ญ์ œํ•œ๋‹ค.

๊ด€์‹ฌ์žˆ์„ ํฌ์ŠคํŒ