Skip to content

Latest commit

ย 

History

History
112 lines (89 loc) ยท 5.22 KB

22_scenario1.md

File metadata and controls

112 lines (89 loc) ยท 5.22 KB

์‹œ๋‚˜๋ฆฌ์˜ค - Pull request

  • ํ˜‘์—…์„ ํ•˜๋‹ค ๋ณด๋ฉด, ํƒ€์ธ ๋˜๋Š” ์กฐ์ง์˜ repository๋ฅผ ๊ณต์šฉ์œผ๋กœ ์ž‘์—…ํ•ด์•ผ ํ•  ๋•Œ๊ฐ€ ์žˆ๋‹ค
  • ์ด๋Ÿฐ ๊ฒฝ์šฐ, ๋‚˜์—๊ฒŒ ๊ถŒํ•œ์ด ์ฃผ์–ด์ง€์ง€ ์•Š์•„ pull request๋ฅผ ์ด์šฉํ•ด ์ž‘์—…์„ ํ•˜๊ฒŒ ๋˜๋Š” ๊ฒฝ์šฐ๊ฐ€ ์ƒ๊ธด๋‹ค
  • ๋˜ํ•œ, main์ด ์•„๋‹Œ ํŠน์ •ํ•œ branch์—์„œ๋งŒ ๊ฐœ๋ฐœํ•˜๋„๋ก ๊ฐ•์ œํ•˜๋Š” ๊ฒฝ์šฐ๋„ ์žˆ๋‹ค
  • ์˜ˆ์ƒ๋˜๋Š” ์‹œ๋‚˜๋ฆฌ์˜ค๋ฅผ ๋”ฐ๋ผ์„œ ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐํ•ด๋ณด์ž


์˜ˆ์ƒ๋˜๋Š” ์—๋Ÿฌ

  • git push -f ์˜ต์…˜์„ ์‚ฌ์šฉํ•  ์ˆ˜ ์—†๋‹ค
    • ๋‚˜์—๊ฒŒ repository๋ฅผ ๋ณ€๊ฒฝํ•  ๊ถŒํ•œ์ด ์—†๊ธฐ ๋•Œ๋ฌธ์—, forced push๊ฐ€ ๋ถˆ๊ฐ€๋Šฅํ•˜๋‹ค
    • ๋•Œ๋ฌธ์— ํ•œ ๋ฒˆ ์‹ค์ˆ˜๋ฅผ ํ•˜๊ฒŒ ๋˜๋ฉด, ๋งค์šฐ ๋‚œ๊ฐํ•ด์ง„๋‹ค
  • pull request์—์„œ ๋ฐœ์ƒํ•˜๋Š” ๋ฌธ์ œ [์ฐธ๊ณ  ์‚ฌ์ดํŠธ]
    • github์—์„œ pull request๋ฅผ mergeํ•˜๋Š” ๋ฐ์—๋Š” Merge, Squash and merge, Rebase and merge ์„ธ ๊ฐ€์ง€ ๋ฐฉ๋ฒ•์„ ์ง€์›ํ•œ๋‹ค
    • ๊ฐ๊ฐ์˜ ๋ฐฉ๋ฒ•์— ๋”ฐ๋ผ ๋‹ค์–‘ํ•œ conflict๊ฐ€ ๋ฐœ์ƒํ•  ์ˆ˜ ์žˆ๋‹ค
  • branch์— ์ต์ˆ™ํ•˜์ง€ ์•Š์•„์„œ ๋ฐœ์ƒํ•˜๋Š” ๋ฌธ์ œ
    • branch๋ฅผ ์ œ๋Œ€๋กœ ์‚ฌ์šฉํ•˜์ง€ ์•Š์œผ๋ฉด, origin ๋˜๋Š” upstream์˜ ๋ชจ๋“  ๋ณ€๊ฒฝ์‚ฌํ•ญ์„ fetch๋ฐ›๋Š” ์‹ค์ˆ˜๋ฅผ ํ•  ์ˆ˜ ์žˆ๋‹ค
    • git log --oneline --graph --all์„ ์ด์šฉํ•ด ๋ฐ”๋ผ๋ณด๋ฉด ์“ธ๋ชจ์—†๋Š” commit๊นŒ์ง€ ๋ชจ๋‘ ๋ฐ›์•„๋ฒ„๋ ค ์ˆ˜์ •์ด ์–ด๋ ค์›Œ์กŒ๋‹ค๋Š” ๊ฒƒ์„ ์•Œ ์ˆ˜ ์žˆ๋‹ค


์‹œ๋‚˜๋ฆฌ์˜ค

Repository fork

  • ๊ฐ€์žฅ ๋จผ์ € ์šฐ๋ฆฌ๊ฐ€ ํ•ด๊ฒฐํ•ด์•ผ ํ•˜๋Š” repository๋ฅผ forkํ•ด์•ผ ํ•œ๋‹ค
  • ์šฐ๋ฆฌ๋Š” ์ด repository๋ฅผ upstream ์ด๋ผ๊ณ  ๋ถ€๋ฅธ๋‹ค
  • upstream์—์„œ Fork ๋ฒ„ํŠผ์„ ๋ˆ„๋ฅด๋ฉด Repositories์— ๋™์ผํ•œ repository๊ฐ€ ํ•˜๋‚˜ ์ƒ๊ธด๋‹ค
  • ์šฐ๋ฆฌ๋Š” ์ด repository๋ฅผ downstream ๋˜๋Š” origin ์ด๋ผ๊ณ  ๋ถ€๋ฅธ๋‹ค
upstream origin


Origin clone branch

  • ์ž‘์—…์„ ํ•˜๊ธฐ ์œ„ํ•ด์„œ origin์—์„œ local๋กœ cloneํ•ด์•ผ ํ•œ๋‹ค
  • ํ•˜์ง€๋งŒ, ์šฐ๋ฆฌ์—๊ฒŒ ๋ฐฐ์ •๋œ ํŠน์ • branch๊ฐ€ ์žˆ์„ ๊ฒฝ์šฐ์—๋Š” ์˜ต์…˜์„ ๋” ์ ์šฉํ•ด์•ผ ํ•œ๋‹ค
  • ๋•Œ๋ฌธ์— git clone -b ๋ธŒ๋žœ์น˜๋ช… --single-branch ์ฃผ์†Œ ๋ช…๋ น์–ด๋ฅผ ์ด์šฉํ•ด์•ผ ํ•œ๋‹ค
  • ์—ฌ๊ธฐ์„œ git branch -v๋ฅผ ํ•ด๋ณด๋ฉด main๋„ ์—†์ด ์šฐ๋ฆฌ๊ฐ€ ๋ฐ›๊ณ ์ž ํ–ˆ๋˜ branch๋งŒ ์กด์žฌํ•œ๋‹ค๋Š” ๊ฒƒ์„ ์•Œ ์ˆ˜ ์žˆ๋‹ค



์ž‘์—… branch ์ƒ์„ฑ

  • ์šฐ๋ฆฌ๋งŒ์˜ branch ์ด๋”๋ผ๋„ ํ•ด๋‹น branch๋ฅผ ๋ฐ”๋กœ ์‚ฌ์šฉํ•˜์ง€๋Š” ์•Š๋Š”๋‹ค
  • ์กฐ์ง์—์„œ ์šฐ๋ฆฌ์—๊ฒŒ ๋ถ€์—ฌํ•œ branch๊ฐ€ ์šฐ๋ฆฌ์˜ main์ด๊ธฐ ๋•Œ๋ฌธ์—, ์—ฌ๊ธฐ์„œ ์ƒˆ๋กœ์šด branch๋ฅผ ์ถ”๊ฐ€๋กœ ๋งŒ๋“ค์–ด ์ถ”ํ›„์— mergeํ•˜๋Š” ๊ฒƒ์ด ์˜ณ๋‹ค
  • ๋Œ€๋ถ€๋ถ„ dev branch๋ฅผ ๋งŒ๋“ค์–ด ์ž‘์—…ํ•œ๋‹ค



์ž‘์—…ํ›„ origin์— push

  • ์–ด๋– ํ•œ ์ž‘์—…์„ ๋งˆ์น˜๊ณ  origin์— pushํ•  ๋•Œ์—๋„ ์˜ต์…˜์ด ๋ถ™๋Š”๋‹ค
  • ์ด ๋•Œ, ์šฐ๋ฆฌ์—๊ฒŒ ๋ฐฐ์ •๋œ FrontPage branch์— ์ ์šฉํ•˜๋ฉด ์•ˆ๋œ๋‹ค
  • ์‹ ์ค‘ํ•˜๊ฒŒ ์šฐ๋ฆฌ๊ฐ€ ๋งŒ๋“  dev branch๋กœ git push origin ๋ธŒ๋žœ์น˜๋ช…์„ ๋ฐ˜๋“œ์‹œ ์ž…๋ ฅํ•ด์ฃผ์ž



Upstream๋กœ pull request

  • origin์˜ repository๋กœ ์˜ค๋ฉด 2๊ฐ€์ง€ ๋ณ€ํ™”๊ฐ€ ์ƒ๊ธด๋‹ค
    • dev branch๊ฐ€ ์ƒ๊ฒผ๋‹ค
    • pull request๋ฅผ ๋ณด๋‚ผ ์ˆ˜ ์žˆ๋‹ค
  • ์—ฌ๊ธฐ์„œ Compare & pull request๋ฅผ ๋ˆŒ๋Ÿฌ์ฃผ์ž
  • ์ด ๋ถ€๋ถ„์—์„œ ๊ฐ€์žฅ ์ค‘์š”ํ•œ ๊ฒƒ์€ base์™€ compare๊ฐ€ ์ž˜ ์ ์šฉ๋˜์—ˆ๋Š”์ง€ ํ™•์ธํ•˜๋Š” ๊ฒƒ์ด๋‹ค
  • Create pull request๋ฅผ ๋ณด๋‚ด๊ณ  ๋‚˜๋ฉด, ๋์ด๋‹ค



Upstream์—์„œ pull

  • ์ด ๋ถ€๋ถ„์€ upstream์˜ ๊ด€๋ฆฌ์ž๊ฐ€ ๋ณด๋Š” ๋‚ด์šฉ์ด๋‹ค
  • downstream์ด pull request๋ฅผ ์ž˜ ๋ณด๋‚ด์—ˆ๋Š”์ง€ ํ™•์ธํ•˜๊ณ , ์ด๋ฅผ ์ˆ˜์šฉํ•˜๊ฑฐ๋‚˜ ๊ฑฐ์ ˆํ•  ์ˆ˜ ์žˆ๋‹ค
  • ์—ฌ๊ธฐ์„œ upstream์€ 3๊ฐ€์ง€ ๋ฐฉ์‹์œผ๋กœ mergeํ•  ์ˆ˜ ์žˆ๋Š”๋ฐ, Rebase and merge ๋ฐฉ์‹์œผ๋กœ ํ•œ๋‹ค๊ณ  ๊ฐ€์ •ํ•˜๊ฒ ๋‹ค



Origin์— ํ•„์š” ์—†์–ด์ง„ branch ์‚ญ์ œ

  • ์ด์ œ dev branch๋Š” ํ•„์š” ์—†์œผ๋ฏ€๋กœ ์‚ญ์ œํ•ด ์ฃผ์–ด์•ผ ํ•œ๋‹ค
  • git branch -D ๋ธŒ๋žœ์น˜๋ช…์„ ์ž…๋ ฅํ•ด์„œ local์—์„œ ์‚ญ์ œํ•ด ์ค€๋‹ค
  • ์ดํ›„ git push origin -d ๋ธŒ๋žœ์น˜๋ช…์„ ์ž…๋ ฅํ•ด์„œ origin์—์„œ ์‚ญ์ œํ•ด ์ค€๋‹ค



Local์—์„œ upstream ๊ฐ€์ ธ์˜ค๊ธฐ

  • ํ˜„์žฌ local์—๋Š” upstream์ด ๋“ฑ๋ก๋˜์–ด ์žˆ์ง€ ์•Š๊ธฐ์— ๋จผ์ € git remote add upstream์„ ํ•ด์•ผ ํ•œ๋‹ค
  • ์ดํ›„ git fetch upstream ๋ธŒ๋žœ์น˜๋ช…์„ ์ด์šฉํ•ด upstream์˜ ํŠน์ • branch๋งŒ fetchํ•˜์ž
  • ์—ฌ๊ธฐ์„œ git rebase upstrea/๋ธŒ๋žœ์น˜๋ช…์œผ๋กœ local์„ upstream๊ณผ ๋™๊ธฐํ™” ํ•ด์ฃผ๋ฉด ๋œ๋‹ค



Local์—์„œ origin ๋™๊ธฐํ™”

  • git log๋ฅผ ๋ณด๋ฉด origin๋งŒ ๋”ฐ๋กœ ์žˆ๋Š” ๊ฒƒ์„ ๋ณผ ์ˆ˜ ์žˆ๋‹ค
  • ์—ฌ๊ธฐ์„œ git push -f origin ๋ธŒ๋žœ์น˜๋ช… ๋ช…๋ น์œผ๋กœ ๋™๊ธฐํ™”ํ•˜๋ฉด ๋ชจ๋“  ์ž‘์—…์ด ์™„๋ฃŒ๋œ๋‹ค