Skip to content

๐Ÿ“ [WIP] Personal git/github guideline about commit convention, git-flow, issue/pull-request templates, etc.

License

Notifications You must be signed in to change notification settings

stevejkang/git-guideline

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

35 Commits
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

git-guideline

Personal git/github guideline about commit convention, git flow, issue/pull-request templates, etc.

Last Commit Hits

Table of Contents

  1. Commit Convention
  2. Git Flow & Branch
  3. Issue
  4. Pull Request
  5. Actions
  6. Wiki
  7. Troubleshooting
  8. Tips
  9. ์ด์ œ ๋ญ˜ํ•˜๋ฉด ๋˜๋‚˜์š”?

1. Commit Convention

์ƒ๋‹จ์œผ๋กœ โฌ†๏ธ

1.1. ์ปค๋ฐ‹์˜ ์ •์˜

1.1.1. ์ž‘์„ฑ์ž

์ปค๋ฐ‹์€ ์ž‘์—…์ž๊ฐ€ ์ง์ ‘ ์ž‘์—…ํ•œ ๋‚ด์šฉ์— ๋Œ€ํ•ด ์ปค๋ฐ‹์„ ํ•ฉ๋‹ˆ๋‹ค.

1.1.2. ๋‹จ์œ„

์ปค๋ฐ‹์€ ์ž‘์—… ํ•˜๋‚˜์˜ ๋‹จ์œ„๊ฐ€ ๋˜์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. ํ–‰๋™ ํ•˜๋‚˜์˜ ๋‹จ์œ„๊ฐ€ ๋˜์–ด์„œ๋Š” ์•ˆ๋ฉ๋‹ˆ๋‹ค.
์˜ˆ๋ฅผ ๋“ค์–ด, Case A๋Š” ๊ฐ€๋Šฅํ•˜์ง€๋งŒ Case B๋Š” ์ปค๋ฐ‹์˜ ๋‹จ์œ„๋กœ ๊ถŒ์žฅํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.

  • Case A
    • CLI๋กœ Vue.js ํ”„๋กœ์ ํŠธ๋ฅผ ์„ค์น˜ํ•œ ๊ฒฝ์šฐ
    • ์˜คํƒ€๋ฅผ ๊ณ ์นœ ๊ฒฝ์šฐ
    • ์—ฌ๋Ÿฌ ๊ฐœ์˜ Dependency๋ฅผ ์„ค์น˜ํ•˜์—ฌ ํ”„๋กœ์ ํŠธ ๊ธฐ๋ฐ˜์„ ๋งŒ๋“  ๊ฒฝ์šฐ
    • ํ•˜๋‚˜ ์ด์ƒ์˜ Dependency๋ฅผ ์„ค์น˜ํ•˜๊ณ  ํ”„๋กœ์ ํŠธ ์–ด๋”˜๊ฐ€์— ์ •์˜, ์ ์šฉํ•œ ๊ฒฝ์šฐ
  • Case B
    • Dependency๋ฅผ ์„ค์น˜ํ•œ ๊ฒฝ์šฐ

1.1.3. ์กฐ๊ฑด

์ปค๋ฐ‹์€ ์ž„์‹œ๋กœ ์ €์žฅ ํ•ด๋‘๊ธฐ ์œ„ํ•œ ์žฅ์น˜๋กœ ์‚ฌ์šฉํ•ด์„œ๋Š” ์•ˆ๋ฉ๋‹ˆ๋‹ค. (git stash ์ปค๋งจ๋“œ ์‚ฌ์šฉ์„ ๊ถŒ์žฅํ•ฉ๋‹ˆ๋‹ค.) ์ฆ‰, ๋ชจ๋“  ์ปค๋ฐ‹์€ ๊ฐœ๋ฐœ ๋‹น์‹œ์— ์™„๊ฒฐ๋œ ์ฝ”๋“œ๋งŒ์ด ์˜ฌ๋ผ๊ฐ€์•ผ ํ•ฉ๋‹ˆ๋‹ค.

1.2. ์ปค๋ฐ‹ ๋ฉ”์„ธ์ง€

์ƒ์„ธํ•œ ์ปค๋ฐ‹ ๋ฉ”์„ธ์ง€๋ฅผ ์ž‘์„ฑํ•˜๋„๋ก ๋…ธ๋ ฅํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. ์Šต๊ด€์ ์œผ๋กœ -m ์˜ต์…˜์„ ๋ถ™์ด๊ณ  single-line ์ปค๋ฐ‹์„ ์ง€์–‘ํ•˜๋„๋ก ํ•ฉ๋‹ˆ๋‹ค. (๋‹น์—ฐํ•˜๊ฒŒ๋„ -m์ด multi-line ์ปค๋ฐ‹์„ ์ž‘์„ฑํ•  ์ˆ˜ ์—†๋‹ค๋Š” ์˜๋ฏธ๋Š” ์•„๋‹™๋‹ˆ๋‹ค. ์—ฌ๊ธฐ์„œ๋Š” ์ข€ ๋” ์ƒ์„ธํ•œ ์ปค๋ฐ‹ ์ •๋ณด๋ฅผ ํ™•์ธํ•˜๊ธฐ ์œ„ํ•ด ์ž…๋ ฅ์ฐฝ์œผ๋กœ ๋“ค์–ด๊ฐ€ ์ž‘์„ฑํ•˜๋Š” ๊ฒƒ์„ ์Šต๊ด€๋“ค์ด๊ธฐ ์œ„ํ•จ์ž…๋‹ˆ๋‹ค.)

1.2.1. ์–ธ์–ด

๋ˆ„๊ตฌ๋‚˜ ๋ดค์„ ๋•Œ ์ดํ•ดํ•  ์ˆ˜ ์žˆ๋„๋ก ์˜์–ด๋กœ ์ž‘์„ฑํ•˜๋Š” ๊ฒƒ์„ ๊ถŒ์žฅํ•ฉ๋‹ˆ๋‹ค.

์–ด๋””๊นŒ์ง€๋‚˜ ๊ถŒ์žฅ์ผ ๋ฟ, ๊ฐ•์ œ ์‚ฌํ•ญ์€ ์•„๋‹ˆ๋ฉฐ, ์‚ฌ๋‚ด์—์„œ ์‚ฌ์šฉํ•˜๋Š” ๊ฒฝ์šฐ๋‚˜ ํ•„์š”์— ๋”ฐ๋ผ์„œ๋Š” ์‚ฌ์šฉํ•˜๊ธฐ ํŽธํ•œ ์–ธ์–ด๋กœ ์„œ์ˆ ํ•˜๋Š” ๊ฒŒ ์ „๋‹ฌ์ด ๋ช…ํ™•ํ•œ ๊ฒฝ์šฐ๋„ ์žˆ์Šต๋‹ˆ๋‹ค. ๋Œ€์‹ , ์˜คํ”ˆ์†Œ์Šค๋ฅผ ๊ฐœ๋ฐœํ•˜๊ณ ์ž ํ•œ๋‹ค๋ฉด, ์˜์–ด๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ์ด ์ข‹์Šต๋‹ˆ๋‹ค.

1.2.2. ๊ตฌ์„ฑ

์•„๋ž˜๋Š” ์ด ๋ ˆํฌ์ง€ํ† ๋ฆฌ์—์„œ ์ œ์•ˆํ•˜๋Š” ์ปค๋ฐ‹ ์ปจ๋ฒค์…˜์ž…๋‹ˆ๋‹ค.

์•„๋ž˜์—์„œ ์„ค๋ช…ํ•˜๋Š” ์ปจ๋ฒค์…˜์€ ๊ฐ€์žฅ ๊ธฐ๋ณธ์ ์ธ ์ปจ๋ฒค์…˜์ž…๋‹ˆ๋‹ค.
์ƒํ™ฉ์— ๋”ฐ๋ผ ๋‹ค์–‘ํ•œ ํฌ๋งท์„ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๊ณ , ์ด๋ฏธ ์‚ฌ์šฉํ•˜๊ณ  ์žˆ๋Š” ์ปจ๋ฒค์…˜์ด ์žˆ๋‹ค๋ฉด ๋‹ค์Œ์œผ๋กœ ๋„˜์–ด๊ฐ€์ฃผ์„ธ์š”.

  • ๊ธฐ๋ณธ ๊ตฌ์„ฑ์€ ๋‹ค์Œ๊ณผ ๊ฐ™์Šต๋‹ˆ๋‹ค.

    <?>๋Š” optional field๋ฅผ ์˜๋ฏธํ•ฉ๋‹ˆ๋‹ค.

    <Commit Title>
    
    <Commit Body>
    - <?Commit Detail>
    <Commit Footer>
    
  • ๋ชจ๋“  ์ค„์€ ๋ฌธ์žฅ์œผ๋กœ ๊ตฌ์„ฑ๋˜๋ฉฐ, ์ฒซ ๋ฌธ์ž๋Š” ๋Œ€๋ฌธ์ž๋กœ, ์ฒซ ๋‹จ์–ด๋Š” ํ˜„์žฌํ˜• ๋™์‚ฌ๋กœ, ๋งˆ์นจํ‘œ๋Š” ์‚ฌ์šฉํ•˜์ง€ ์•Š์•„์•ผ ํ•ฉ๋‹ˆ๋‹ค. ๊ธฐํƒ€ ๊ธฐํ˜ธ ๋˜๋Š” ํŠน์ˆ˜๋ฌธ์ž(emoji ํฌํ•จ)๋Š” ํ•„์š”ํ•œ ๊ฒฝ์šฐ๋ฅผ ์ œ์™ธํ•˜๊ณ ๋Š” ์‚ฌ์šฉ์„ ๊ถŒ์žฅํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.

    • ์˜ˆ์™ธ์‚ฌํ•ญ
      • ๋ฉ”์†Œ๋“œ๋ช… getMessage()
      • ํŒŒ์ผ๋ช… getMessage.js
    • ์˜ˆ์‹œ
      • Fix calculation in process.uptime()
  • ์„ธ ์ค„ ์ด์ƒ ์ž‘์„ฑํ•ด์•ผ ํ•˜๊ณ , ์ปค๋ฐ‹์˜ ๋‘ ๋ฒˆ์งธ ์ค„์€ ๋ฐ˜๋“œ์‹œ ๋น„์›Œ์•ผ ํ•ฉ๋‹ˆ๋‹ค. ์„ธ ๋ฒˆ์งธ ์ค„์˜ ํ•ญ๋ชฉ๋ถ€ํ„ฐ ์ƒ์„ธ ๋‚ด์šฉ์„ ์ถ”๊ฐ€( - + ๋‚ด์šฉ)ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

    • ์˜ˆ์™ธ์‚ฌํ•ญ
      • ์˜คํƒ€ ์ˆ˜์ • Fix typo
    • ์˜ˆ์‹œ
      Prevent multiple connection errors
      
      Catch error caused by network error
      - Use try catch expression
      
  • ์ด์Šˆ๊ฐ€ ํ•ด๊ฒฐ๋œ ๋‚ด์šฉ์€ ์ปค๋ฐ‹ ์ตœํ•˜๋‹จ์— Fix #7์™€ ๊ฐ™์€ ์šฉ๋ฒ•์œผ๋กœ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

    ๋˜๋Š” PR๋กœ ์˜ฌ๋ผ๊ฐˆ ์ปค๋ฐ‹์ด ์•„๋‹ˆ๋ผ๋ฉด ๊ฐ„๋‹จํžˆ ๋ฉ”์„ธ์ง€ ๋’ค์— (#7)๊ณผ ๊ฐ™์ด reference ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

  • ์ปค๋ฐ‹์˜ ์ œ๋ชฉ ๋˜๋Š” ๋ณธ๋ฌธ์— ๊ฐ€์žฅ ๋จผ์ € ๋‚˜ํƒ€๋‚˜๋Š” ํ˜„์žฌํ˜• ๋™์‚ฌ๋Š” ๋‹ค์Œ์„ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค.

    • Fix [๊ธฐ๋Šฅ์ˆ˜์ •]
      • Fix A: A ์ˆ˜์ •
      • Fix A in B: B์˜ A ์ˆ˜์ •
      • Fix A which B/Fix A that B: B์ธ A ์ˆ˜์ •
      • Fix A to B/Fix A to be B: B๋ฅผ ์œ„ํ•ด A ์ˆ˜์ • | Bํ•˜๊ธฐ ์œ„ํ•ด A ์ˆ˜์ •
      • Fix A so that B: A ์ˆ˜์ •ํ•ด์„œ B (B ์ƒํƒœ ๊ฐ•์กฐ)
      • Fix A[issue|error|crash] where B: Bํ•˜๋Š” A ์ˆ˜์ •
      • Fix A when B: B์— ๋ฐœ์ƒํ•˜๋Š” A ์ˆ˜์ •
    • Add [์ถ”๊ฐ€(์ฝ”๋“œ/ํ…Œ์ŠคํŠธ/๋ฌธ์„œ)]
      • Add A: A ์ถ”๊ฐ€
      • Add A for B: B๋ฅผ ์œ„ํ•œ A ์ถ”๊ฐ€
      • Add A to B: B์— A ์ถ”๊ฐ€
    • Remove [์‚ญ์ œ(์ฝ”๋“œ/๋ฌธ์„œ)]

      ๋ณดํ†ต (unnecessary|useless|unneeded|unused|duplicated) + A ํ˜•ํƒœ

      • Remove A: A ์‚ญ์ œ
      • Remove A from B: B์—์„œ A ์‚ญ์ œ
    • Use [์‚ฌ์šฉ]
      • Use A: A ์‚ฌ์šฉ
      • Use A for B: B๋ฅผ ์œ„ํ•œ A ์‚ฌ์šฉ
      • Use A to B: B์— A ์‚ฌ์šฉ (to-๋ถ€์ •์‚ฌ B ํ—ˆ์šฉ)
      • Use A in B: B์— A ์‚ฌ์šฉ | B ๋‚ด๋ถ€์—์„œ A ์‚ฌ์šฉ
      • Use A instead of B: B ๋Œ€์‹ ์— A ์‚ฌ์šฉ
    • Apply [์ ์šฉ]
      • Apply A: A ์ ์šฉ
      • Apply A to B: B์— A ์ ์šฉ
    • Refactor [๋ฆฌํŒฉํ† ๋ง(ํ–‰์œ„/๊ธฐ๋Šฅ/๋ฉ”์†Œ๋“œ)]
      • Refactor A: A ๋ฆฌํŒฉํ† ๋ง
    • Simplify [๋‹จ์ˆœํ™”(ํ–‰์œ„/๊ธฐ๋Šฅ/๋ฉ”์†Œ๋“œ)]
      • Simplify A: A ๋‹จ์ˆœํ™”
    • Update [์—…๋ฐ์ดํŠธ/๋ฒ„์ „ ์—…(๋ฌธ์„œ/๋ฆฌ์†Œ์Šค)]
      • Update A: A ์ตœ์‹ ํ™”
      • Update A to B: A๋ฅผ B๋กœ ์ตœ์‹ ํ™”
      • Update A for B: B๋ฅผ ์œ„ํ•œ A ์—…๋ฐ์ดํŠธ
    • Change [๋ณ€๊ฒฝ]
      • Change A: A ๋ณ€๊ฒฝ
      • Change A into B: A๋ฅผ B๋กœ ๋ณ€๊ฒฝ
    • Improve/Enhance [ํ–ฅ์ƒ/๊ฐœ์„ (ํ…Œ์ŠคํŠธ/์ปค๋ฒ„๋ฆฌ์ง€/์„ฑ๋Šฅ)]
      • Improve A: A ํ–ฅ์ƒ
    • Make [๋™์ž‘ ๋ณ€๊ฒฝ]
      • Make A B: A๋ฅผ Bํ•˜๊ฒŒ ํ•˜๋‹ค (to-๋ถ€์ •์‚ฌ B ํ—ˆ์šฉ) | A๋ฅผ B๋กœ ๋งŒ๋“ค๋‹ค
    • Implement [Add ๋ณด๋‹ค ํฐ ๊ตฌํ˜„]
      • Implement A: A ๊ตฌํ˜„
      • Implement A to B: B์— A ๊ตฌํ˜„
    • Correct [(๋ฌธ๋ฒ•/ํƒ€์ž… ๋“ฑ์„) ๋งž๋„๋ก ์ˆ˜์ •]
      • Correct A: A๋ฅผ ๋งž๊ฒŒ ํ•˜๋‹ค
    • Ensure/Make sure [๊ฒ€์ฆ]
      • Ensure A: A๋ฅผ ํ™•์‹คํ•˜๊ฒŒ ํ•˜๋‹ค
    • Prevent [์ ‘๊ทผ์ œํ•œ]
      • Prevent A: A๋ฅผ ๋ง‰๋‹ค
      • Prevent A from B: A๋ฅผ Bํ•˜์ง€ ๋ชปํ•˜๊ฒŒ ๋ง‰๋‹ค
    • Avoid [(์กฐ๊ฑด ๋“ฑ์„) ํ”ผํ•˜๋‹ค]
      • Avoid A: A๋ฅผ ํ”ผํ•˜๋‹ค.
      • Avoid A if B/Avoid A when B: B์ผ ๋•Œ A์— ๊ฑธ๋ฆฌ์ง€ ์•Š๋„๋ก ํ•˜๋‹ค
    • Move [์ด๋™(์ฝ”๋“œ/๋ฌธ์„œ)]
      • Move A to B/Move A into B: A๋ฅผ B๋กœ ์ด๋™ํ•˜๋‹ค
    • Rename [์ด๋ฆ„ ์ˆ˜์ •(์ฝ”๋“œ/๋ฌธ์„œ/๋ฉ”์†Œ๋“œ)]
      • Rename A to B: A๋ฅผ B๋กœ ์ด๋ฆ„์„ ๋ฐ”๊พธ๋‹ค
    • Allow [ํ—ˆ์šฉ]
      • Allow A to B: A๊ฐ€ Bํ•  ์ˆ˜ ์žˆ๋„๋ก ํ—ˆ์šฉ
    • Verify [๊ฒ€์ฆ]
      • Verify A: A๋ฅผ ๊ฒ€์ฆ
    • Set [์„ค์ •(๋ณ€์ˆ˜/๊ฐ’)]
      • Set A to B: A๋ฅผ B๋กœ ์„ค์ •
    • Pass [ํŒŒ๋ผ๋ฉ”ํ„ฐ]
      • Pass A to B: A๋ฅผ B๋กœ ๋„˜๊ธฐ๋‹ค
    • Disable [๋น„ํ™œ์„ฑํ™”]
      • Disable A: A๋ฅผ ๋น„ํ™œ์„ฑํ™” ํ•˜๋‹ค
    • Organize [์ •๋ฆฌ]
      • Organize A: A ์ •๋ฆฌ

2. Git Flow & Branch

์ƒ๋‹จ์œผ๋กœ โฌ†๏ธ

2.1. ๊ฐœ์š”

2.1.1. ์ •์˜

Git Flow๋Š” ๋ฒ„์ „ ๊ด€๋ฆฌ ์‹œ์Šคํ…œ(Version Control System, VCS)์˜ ํ•œ ์ข…๋ฅ˜์ธ git์„ ํ†ตํ•ด ํšจ์œจ์ ์œผ๋กœ ํ”„๋กœ์ ํŠธ๋ฅผ ๊ด€๋ฆฌํ•˜๊ณ  ๋ฐฐํฌํ•˜๊ธฐ ์œ„ํ•œ ์ „๋žต์ด์ž ๋ธŒ๋žœ์นญ ๊ด€๋ฆฌ ์ „๋žต(Branch Management Strategy) ์ž…๋‹ˆ๋‹ค. ์‹ค์ œ ํ”„๋กœ๋•ํŠธ๋ฅผ ๊ฐœ๋ฐœํ•˜๊ณ  ์ง€์†์ ์œผ๋กœ ๋ฐฐํฌํ•˜๋Š” ์กฐ์ง์—์„œ ๊ถŒ์žฅ๋˜๋Š” ๋ฐฉ๋ฒ•์ด์ง€๋งŒ, ์‹ค์ œ๋กœ ๊ฐœ๋ฐœ ์กฐ์ง์— ์ ์šฉํ•˜๋Š” ๋ฐฉ์‹์€ ๊ฐ๊ธฐ ๋‹ค๋ฅผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

์•„๋ž˜์—์„œ๋Š” Best Practice๋ฅผ ๋‹ด์œผ๋ ค ๋…ธ๋ ฅํ•˜์˜€์œผ๋‚˜, ์กฐ์ง๊ณผ ํ”„๋กœ์ ํŠธ์˜ ์„ฑ๊ฒฉ์— ๋งž๊ฒŒ ์กฐ์ •์ด ํ•„์š”ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

์ด ์„น์…˜์—์„œ ๋งํ•˜๋Š” Branch๋Š” Git Flow์˜ ๋ธŒ๋žœ์นญ ๊ด€๋ฆฌ ์ „๋žต์„ ๋”ฐ๋ฅด๋Š” ๋ธŒ๋žœ์น˜์— ๋Œ€ํ•œ ์„ค๋ช…์ž…๋‹ˆ๋‹ค. ๋”ฐ๋ผ์„œ ๊ธฐ๋ณธ์ ์ธ git branch ๋ช…๋ น์–ด์— ๋Œ€ํ•œ ์„ค๋ช…์„ ํฌํ•จํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค. ์ฆ‰, ๊ธฐ๋ณธ์ ์œผ๋กœ branch๋ฅผ ๋งŒ๋“ค๊ณ , ์ด๋™ํ•˜๋ฉฐ, ์‚ญ์ œํ•˜๋Š” ๋“ฑ์˜ ๊ธฐ์ดˆ์ง€์‹์ด ์š”๊ตฌ๋ฉ๋‹ˆ๋‹ค.

Git Flow๋Š” GitHub Flow์™€ ๋‹ค๋ฆ…๋‹ˆ๋‹ค. ๋ฌด์—‡์ด ๋” ์ข‹์€ ์ง€์— ๋Œ€ํ•œ ๋…ผ์˜๋Š” ์—ฌ๊ธฐ์—์„œ ํ™•์ธํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๊ฐ€์žฅ ๋จผ์ € ์ œ์•ˆ๋œ ๋ชจ๋ธ(classic version)์€ Git Flow์ด์ง€๋งŒ, CI/CD๊ฐ€ ์กด์žฌํ•œ๋‹ค๋ฉด, ๋˜๋Š” ๋‹ค์–‘ํ•œ ์‹œ๋„๊ฐ€ ํ•„์š”ํ•œ ์• ์ž์ผ ์กฐ์ง์—์„œ๋Š” GitHub Flow๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ์ด ๋‚˜์€ ๋ฐฉ๋ฒ•์ธ ๊ฒฝ์šฐ๋„ ์žˆ์Šต๋‹ˆ๋‹ค.

2.2. ๋ฐฉ๋ฒ•

Vincent Driessen์ด ์ œ์•ˆํ•œ Git Flow๋Š” ๋‹ค์Œ PDF๋กœ ํ•œ ๋ˆˆ์— ํ™•์ธํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

2.2.1. ๋ธŒ๋žœ์น˜ ์ „๋žต

Git Flow์—์„œ๋Š” ์šฉ๋„/ํ™˜๊ฒฝ์— ๋”ฐ๋ผ ๋ธŒ๋žœ์น˜๋ฅผ ๊ตฌ๋ถ„ํ•ฉ๋‹ˆ๋‹ค. ๋ฉ”์ธ ๋ธŒ๋žœ์น˜๋Š” master, develop ๋ธŒ๋žœ์น˜๊ฐ€ ํ•ด๋‹น๋˜๋ฉฐ, ๊ทธ ์™ธ์— ๋ณด์กฐ ๋ธŒ๋žœ์น˜๋Š” feature, release, hotfix, bugfix ๋ธŒ๋žœ์น˜ ๋“ฑ์ด ํ•ด๋‹น๋ฉ๋‹ˆ๋‹ค.

  • master
    ํ”„๋กœ์ ํŠธ์˜ ๋ฟŒ๋ฆฌ๊ฐ€ ๋˜๋Š” ๋ธŒ๋žœ์น˜๋กœ, ํ•ด๋‹น ๋ธŒ๋žœ์น˜์˜ HEAD๋Š” production ํ™˜๊ฒฝ์— ๋ฐฐํฌ๋˜์—ˆ๊ฑฐ๋‚˜, ๊ณง ๋ฐฐํฌ๋  ์˜ˆ์ •์ž„(production-ready)์„ ์˜๋ฏธํ•ฉ๋‹ˆ๋‹ค. ์‹ค์ œ ์„œ๋น„์Šค์—์„œ๋Š” ์‹ค ์„œ๋ฒ„์™€ sync๊ฐ€ ๋งž์•„์•ผ ํ•ฉ๋‹ˆ๋‹ค.
    master ๋ธŒ๋žœ์น˜์— ๋ฐ˜์˜ ํ˜น์€ ๋ณ‘ํ•ฉ๋œ๋‹ค๋Š” ๊ฒƒ์€ ์ƒˆ ๋ฒ„์ „์ด ๋ฐฐํฌ๋จ์„ ์˜๋ฏธํ•ฉ๋‹ˆ๋‹ค. ๋ณดํ†ต ์‹ค์ œ ์„œ๋ฒ„๋กœ ๋นŒ๋“œ & ๋ฐฐํฌํ•˜๋Š” ์Šคํฌ๋ฆฝํŠธ๊ฐ€ ์ž‘๋™ํ•ฉ๋‹ˆ๋‹ค.

  • develop
    ๋‹ค์Œ ๋ฐฐํฌ๋ฅผ ์œ„ํ•ด ๊ฐœ๋ฐœ๋˜๊ณ  ์žˆ๋Š” ์ฝ”๋“œ๊ฐ€ ์œ„์น˜ํ•˜๋Š” ๋ธŒ๋žœ์น˜. ์‹ค์ œ ์„œ๋น„์Šค์—์„œ๋Š” ๊ฐœ๋ฐœ ์„œ๋ฒ„ ํ˜น์€ ํ…Œ์ŠคํŠธ ์„œ๋ฒ„์™€ sync๊ฐ€ ๋งž์•„์•ผ ํ•ฉ๋‹ˆ๋‹ค.
    develop ๋ธŒ๋žœ์น˜๊ฐ€ ์•ˆ์ •ํ™”๋˜๊ณ , ๋ฐฐํฌ ๊ธฐ๋Šฅ์ด ์™„์„ฑ๋˜๋ฉด, master๋กœ ๋ณ‘ํ•ฉ๋ฉ๋‹ˆ๋‹ค.

    ๋ธŒ๋žœ์น˜ ์ƒ์„ธ
    develop ์‹œ์ž‘๋ธŒ๋žœ์น˜ master
    ๋ณ‘ํ•ฉ๋ธŒ๋žœ์น˜(๋ฐฉํ–ฅ/์ˆœ์„œ) master
    ๋„ค์ด๋ฐ ๊ทœ์น™ develop
  • feature
    feature ๋ธŒ๋žœ์น˜๋Š” ๊ฐœ๋ฐœํ•˜๊ณ ์ž ํ•˜๋Š” ๊ธฐ๋Šฅ์„ ๊ฐœ๋ฐœํ•˜๋Š” ์ฃผ์ถ•์ด ๋˜๋Š” ๋ธŒ๋žœ์น˜์ž…๋‹ˆ๋‹ค. ๋งŒ์•ฝ ์• ์ž์ผ ๋ฐฉ๋ฒ•๋ก ์„ ์ฑ„ํƒํ•œ ์กฐ์ง์ด๋ผ๋ฉด, ์Šคํ”„๋ฆฐํŠธ ๊ธฐ๊ฐ„ ์ค‘ ํ•˜๋‚˜์˜ ์Šคํ† ๋ฆฌ ํ˜น์€ ํ•˜๋‚˜์˜ ์—ํ”ฝ์ด ์ด์— ํ•ด๋‹นํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
    ์ด ๋ธŒ๋žœ์น˜๋Š” ์„ฑ๊ณต์ ์œผ๋กœ develop์— ๋ณ‘ํ•ฉ๋˜๊ฑฐ๋‚˜ ํ•„์š”์„ฑ์ด ์—†์–ด์ง„ ๊ฒฝ์šฐ ์‚ญ์ œํ•˜์—ฌ ๊ด€๋ฆฌํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

    ๋„ค์ด๋ฐ ๊ทœ์น™์—์„œ feature-*๊ฐ€ ๋ณธ๋ž˜ ๊ถŒ์žฅ๋˜๋Š” ํ˜•์‹์ด๋‚˜, SourceTree ๋“ฑ GUI ํ™˜๊ฒฝ์—์„œ ํด๋”๊ตฌ์กฐ๋กœ ํ‘œ์‹œ๋œ๋‹ค๋Š” ์ด์  ๋•Œ๋ฌธ์— feature/*๋กœ ์‚ฌ์šฉํ•˜๊ธฐ๋„ ํ•ฉ๋‹ˆ๋‹ค.

    ๋ธŒ๋žœ์น˜ ์ƒ์„ธ
    feature ์‹œ์ž‘๋ธŒ๋žœ์น˜ develop
    ๋ณ‘ํ•ฉ๋ธŒ๋žœ์น˜(๋ฐฉํ–ฅ/์ˆœ์„œ) develop / master
    ๋„ค์ด๋ฐ ๊ทœ์น™ feature-* ๋˜๋Š” feature/*
  • work
    ๊ฐœ์ธ๋ณ„ ์ž‘์—…์„ ์œ„ํ•œ ๋ธŒ๋žœ์น˜. ์ด๋Š” Git Flow์— ํ•ด๋‹นํ•˜๋Š” ๋‚ด์šฉ์€ ์•„๋‹ˆ์ง€๋งŒ, optionalํ•˜๊ฒŒ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋Š” ๋ธŒ๋žœ์น˜๋กœ, feature์—์„œ ๋ถ„๊ธฐ๋˜์–ด ๊ธฐ๋Šฅ ๊ฐœ๋ฐœ์— ์‚ฌ์šฉ๋˜๋ฉฐ, ์ž‘์—…์ž๋ณ„ ์›ํ™œํ•œ ์ž‘์—…์„ ์œ„ํ•ด ๋งŒ๋“œ๋Š” ๊ฒƒ์„ ๊ถŒ์žฅํ•ฉ๋‹ˆ๋‹ค.

    ์ผ๋ถ€ ์กฐ์ง์—์„œ๋Š” fork์˜ ํ˜•ํƒœ๋กœ repository๋ฅผ ๋ถ„๋ฆฌํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ์ฑ„ํƒํ•˜๊ธฐ๋„ ํ•ฉ๋‹ˆ๋‹ค.

    ๋ธŒ๋žœ์น˜ ์ƒ์„ธ
    work ์‹œ์ž‘๋ธŒ๋žœ์น˜ feature
    ๋ณ‘ํ•ฉ๋ธŒ๋žœ์น˜(๋ฐฉํ–ฅ/์ˆœ์„œ) feature / develop / master
    ๋„ค์ด๋ฐ ๊ทœ์น™ ex) steve-* ๋˜๋Š” steve/*

์—ฌ๊ธฐ๊นŒ์ง€ ์ •๋ฆฌํ•ด๋ณด๋ฉด ์ „์ฒด์ ์ธ ๋ธŒ๋žœ์น˜ ๋ถ„๊ธฐ์˜ depth๋ฅผ ๊ฐ€์žฅ ์œ„์˜ ๊ณ„์ธต๋ถ€ํ„ฐ ๋‚˜ํƒ€๋‚ด๋ฉด ์•„๋ž˜์™€ ๊ฐ™์Šต๋‹ˆ๋‹ค.

master -> develop -> feature/* -> work/*

develop ๋ธŒ๋žœ์น˜์—์„œ๋Š” ์—ฌ๋Ÿฌ ๊ฐœ์˜ feature ๋ธŒ๋žœ์น˜๊ฐ€ ๋ถ„๊ธฐ๋  ์ˆ˜ ์žˆ์œผ๋ฉฐ, ํ•˜๋‚˜์˜ feature ๋ธŒ๋žœ์น˜์—๋Š” ์—ฌ๋Ÿฌ๊ฐœ์˜ work ๋ธŒ๋žœ์น˜๊ฐ€ ๋ถ„๊ธฐ๋  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

์•„๋ž˜๋Š” release, hotfix, bugfix ๋ธŒ๋žœ์น˜๋กœ, ๊ฐ๊ฐ์˜ ์ƒํ™ฉ์— ๋”ฐ๋ผ ์‚ฌ์šฉ๋˜๋Š” ๋ณด์กฐ ๋ธŒ๋žœ์น˜์ž…๋‹ˆ๋‹ค.

  • release
    ์ตœ์ข… ํ”„๋กœ๋•์…˜์œผ๋กœ ์˜ฌ๋ฆด ์ƒํƒœ๊ฐ€ ๋˜์—ˆ์„ ๋•Œ, ์ด๋ฅผ master๋กœ ๋ฐ˜์˜ํ•˜๊ธฐ ์ง์ „์— ์ƒ์„ฑ๋˜๋Š” ๋ธŒ๋žœ์น˜. ๋ณดํ†ต์˜ ๊ฒฝ์šฐ, develop์€ master๋ณด๋‹ค ์—…๋ฐ์ดํŠธ ์ฃผ๊ธฐ๊ฐ€ ์งง๊ธฐ ๋•Œ๋ฌธ์—, develop์—์„œ ์ž‘์—… ์ค‘์ธ ํ•œ ์‹œ์ ์—์„œ release ๋ธŒ๋žœ์น˜๋ฅผ ์ƒ์„ฑํ•˜์—ฌ, ์ตœ์ข…์ ์ธ ๋ฆด๋ฆฌ์ฆˆ ์ค€๋น„๋ฅผ ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
    ์ด๋ ‡๊ฒŒ ์ง„ํ–‰ํ•  ๊ฒฝ์šฐ, ์ฒ˜์Œ release๊ฐ€ ๋ถ„๊ธฐ๋˜๊ณ  ๊ทธ ์ดํ›„์— develop์— ์—…๋ฐ์ดํŠธ ๋˜๋Š” ๋‚ด์šฉ๋“ค์€ ๋‹ค์Œ release ๋ธŒ๋žœ์น˜๊ฐ€ ๋ถ„๊ธฐ๋  ๋•Œ ๋ฐ˜์˜ํ•˜๊ฒŒ ๋˜์–ด, ํ˜„์žฌ ๋ถ„๊ธฐ๋œ release ๋ธŒ๋žœ์น˜์— ํ•œํ•ด ์ •ํ™•ํ•œ ๋ฒ”์œ„ ๋‚ด์— ์—…๋ฐ์ดํŠธ๋ฅผ ์ง„ํ–‰ํ•  ์ˆ˜ ์žˆ๊ฒŒ ๋ฉ๋‹ˆ๋‹ค.
    ์ด ๋ธŒ๋žœ์น˜๊ฐ€ master๋กœ ๋ฐ˜์˜๋  ๋•Œ, ํƒœ๊ทธ๋ฅผ ์ด์šฉํ•ด ๋ฒ„์ €๋‹(versioning)์„ ์ง„ํ–‰ํ•˜๋Š” ๊ฒƒ์„ ๊ถŒ์žฅํ•˜๋ฉฐ, ๋ฐ˜์˜ ํ›„์—๋Š” develop์—๋„ ๋™์ผํ•œ ๋‚ด์šฉ์„ ๋ณ‘ํ•ฉํ•ฉ๋‹ˆ๋‹ค.

    ๋ธŒ๋žœ์น˜ ์ƒ์„ธ
    release ์‹œ์ž‘๋ธŒ๋žœ์น˜ develop
    ๋ณ‘ํ•ฉ๋ธŒ๋žœ์น˜(๋ฐฉํ–ฅ/์ˆœ์„œ) master / develop
    ๋„ค์ด๋ฐ ๊ทœ์น™ release-* ๋˜๋Š” release/*
  • hotfix
    ๋ฏธ๋ฆฌ ๊ณ„ํš๋˜์ง€ ๋ชปํ•œ ๋ฐฐํฌ๋ฅผ ์œ„ํ•œ ๋ธŒ๋žœ์น˜. ์‹ค์ œ ํ”„๋กœ๋•์…˜์— ์žฅ์• ๋ฅผ ์ผ์œผํ‚ฌ ์ •๋„์˜ ํฌ๋ฆฌํ‹ฐ์ปฌ(critical)ํ•œ ์ด์Šˆ๊ฐ€ ๋ฐœ์ƒ๋˜์–ด ๊ธด๊ธ‰ํžˆ ์ˆ˜์ •ํ•ด์•ผ ํ•  ๋•Œ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค.
    ์ด์ „ release ๋ธŒ๋žœ์น˜๊ฐ€ master์— ๋ฐ˜์˜๋œ ์‹œ์ (ํƒœ๊ทธ๋กœ ๋ฒ„์ €๋‹๋œ ์‹œ์ )์—์„œ hotfix ๋ธŒ๋žœ์น˜๋ฅผ ๋ถ„๊ธฐํ•˜์—ฌ ์ด๋ฅผ master, develop ์ˆœ์œผ๋กœ ๋ฐ˜์˜์„ ์ง„ํ–‰ํ•ฉ๋‹ˆ๋‹ค.

    ๋ธŒ๋žœ์น˜ ์ƒ์„ธ
    hotfix ์‹œ์ž‘๋ธŒ๋žœ์น˜ master
    ๋ณ‘ํ•ฉ๋ธŒ๋žœ์น˜(๋ฐฉํ–ฅ/์ˆœ์„œ) master / develop
    ๋„ค์ด๋ฐ ๊ทœ์น™ hotfix-* ๋˜๋Š” hotfix/*
  • bugfix
    ๊ธฐ์กด์— ๋ฆฌํฌํŒ…๋œ ์ด์Šˆ ํ˜น์€ ๋ฒ„๊ทธ๋ฅผ ํ•ด๊ฒฐํ•˜๊ธฐ ์œ„ํ•ด ์ƒ์„ฑ๋˜๋Š” ๋ธŒ๋žœ์น˜. ๋ณดํ†ต fix ๋ธŒ๋žœ์น˜๋ผ๊ณ  ๋ถˆ๋ฆฌ๊ธฐ๋„ ํ•˜๋ฉฐ, ์„œ๋น„์Šค์— ์ค‘๋Œ€ํ•œ ์˜ํ–ฅ์„ ๋ผ์น˜์ง„ ์•Š์ง€๋งŒ, ๊ธฐ๋Šฅ์œผ๋กœ ๋ถ„๋ฅ˜๋  ์ˆ˜ ์—†๊ณ , ๋ฒ„๊ทธ๋ผ ํŒ๋‹จ๋˜๋Š” ๊ฒฝ์šฐ, ์ด๋ฅผ ์„œ๋น„์Šค์— ๋ฐ˜์˜ํ•˜๊ธฐ ์œ„ํ•ด ์ƒ์„ฑํ•ฉ๋‹ˆ๋‹ค.
    ๋ณดํ†ต develop์—์„œ ๋ถ„๊ธฐ๋˜์–ด ์ด๋ฅผ develop, master ์ˆœ์œผ๋กœ ๋ณ‘ํ•ฉ๋˜๋ฉฐ, ํ‘œ๋ฉด์ ์œผ๋กœ๋Š” feature ๋ธŒ๋žœ์น˜์™€ ๋™์ผํ•ฉ๋‹ˆ๋‹ค.

    ๋ธŒ๋žœ์น˜ ์ƒ์„ธ
    bugfix ์‹œ์ž‘๋ธŒ๋žœ์น˜ develop
    ๋ณ‘ํ•ฉ๋ธŒ๋žœ์น˜(๋ฐฉํ–ฅ/์ˆœ์„œ) develop / master
    ๋„ค์ด๋ฐ ๊ทœ์น™ bugfix-* ๋˜๋Š” bugfix/*

2.3. ์ ์šฉ

2.3.1. ์ผ๋ฐ˜์ ์ธ ํ”Œ๋กœ์šฐ

์ด ์„น์…˜์—์„œ ๋งํ•˜๋Š” '์ผ๋ฐ˜์ ์ธ' ํ”Œ๋กœ์šฐ๋ž€ ๋ฆด๋ฆฌ์ฆˆ ํ˜น์€ ํ•ซํ”ฝ์Šค์™€ ๊ฐ™์€ ์ƒํ™ฉ์„ ์ œ์™ธํ•œ ๊ฐ€์žฅ ๋ณดํŽธ์ ์ธ ์ƒํ™ฉ(common case)์„ ๋‹ค๋ฃน๋‹ˆ๋‹ค. ์กฐ์ง์— ๋”ฐ๋ผ work(๊ฐœ์ธ ์ž‘์—…) ๋ธŒ๋žœ์น˜ ๋Œ€์‹ ์— forkํ•˜์—ฌ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๊ณ , merge ์ „์— rebase๋ฅผ ํƒํ•  ์ˆ˜๋„ ์žˆ์Šต๋‹ˆ๋‹ค. (2.4.1. merge์™€ rebase ๋ฌด์—‡์ด ์ •๋‹ต์ผ๊นŒ? ์ฐธ๊ณ )

๊ทธ๋Ÿฌ๋‹ˆ ์ด ๋ ˆํฌ์ง€ํ† ๋ฆฌ์—์„œ๋Š” merge ์ „์— rebase๋ฅผ ํ•˜๋Š” ๋ณ‘ํ•ฉ ํ”Œ๋กœ์šฐ, ๊ทธ๋ฆฌ๊ณ  ๋ธŒ๋žœ์น˜ ๊ด€๋ฆฌ ์ „๋žต์„ ๊ฐ•๋ ฅํ•˜๊ฒŒ ๊ถŒ์žฅํ•ฉ๋‹ˆ๋‹ค. ํ•ด๋‹น ๋ฐฉ๋ฒ•์€ rebase ํ›„์— fast-forward merge๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๊น”๋”ํ•œ ๋ธŒ๋žœ์น˜๋ฅผ ์œ ์ง€ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์ด ๋ฐฉ๋ฒ•์€ ๋’ค์— ๋‚˜์˜ค๋Š” 2.3.2. ๋ฆด๋ฆฌ์ฆˆ ํ”Œ๋กœ์šฐ์™€ 2.3.3. ํ•ซํ”ฝ์Šค ํ”Œ๋กœ์šฐ์—์„œ๋„ ๋™์ผํ•˜๊ฒŒ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค.

WIP general flow

2.3.2. ๋ฆด๋ฆฌ์ฆˆ ํ”Œ๋กœ์šฐ

WIP release flow

2.3.3. ํ•ซํ”ฝ์Šค ํ”Œ๋กœ์šฐ

WIP hotfix flow

2.4. ๊ณ ๋ฏผํ•ด๋ณผ ๋‚ด์šฉ

2.4.1. merge ์ „์— rebase๋ฅผ ํ•ด์•ผ ํ•˜๋Š” ์ด์œ 

merge
feature/order์—์„œ ๋ถ„๊ธฐํ•œ steve/pg ๋ธŒ๋žœ์น˜๊ฐ€ ์žˆ๋‹ค๊ณ  ๊ฐ€์ •ํ•ฉ๋‹ˆ๋‹ค.

[feature/order] git commit -m "a"
[feature/order] git commit -m "b"
[feature/order] git checkout -b steve/pg
[steve/pg] git commit -m "x"
[steve/pg] git commit -m "y"

                (a)     (b)
feature/order   * ----- *
                         \
steve/pg                  ----- * ----- *
                                (x)     (y)

์œ„ ์ƒํƒœ์—์„œ ์ž‘์—… ๋‚ด์šฉ์„ feature/order๋กœ ๋ณ‘ํ•ฉํ•˜๋ ค ํ•  ๋•Œ, ๋งŒ์•ฝ ๋‹ค๋ฅธ ํŒ€์›์ด feature/order ๋ธŒ๋žœ์น˜์— ๋ฐ˜์˜ํ•œ ๋‚ด์šฉ์ด ์—†๊ณ , ๋ถ„๊ธฐ ์ดํ›„๋กœ ์ง„ํ–‰๋œ ์ปค๋ฐ‹์ด ์—†๋‹ค๋Š” ๊ฒƒ์ด origin์œผ๋กœ๋ถ€ํ„ฐ ํ™•์ธ๋˜๋ฉด, fast-forward merge ํ˜น์€ non-fast-forward merge๋ฅผ ์ง„ํ–‰ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

  • fast-forward merge๋ฅผ ํ•˜๋ฉด ๋‹ค์Œ๊ณผ ๊ฐ™์Šต๋‹ˆ๋‹ค.

    [steve/pg] git checkout feature/order
    [feature/order] git merge --ff-only steve/pg

    ์ด ๊ฒฝ์šฐ์—๋Š” ์ƒ์œ„ ๋ธŒ๋žœ์น˜์— ๋ณ€๊ฒฝ์‚ฌํ•ญ์ด ์—†์œผ๋ฏ€๋กœ ๋’ค์—์„œ ๋‚˜์˜ฌ rebase์™€ ๋™์ผํ•˜๊ฒŒ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. (์•„๋ž˜์—์„œ ๋‚˜์˜ฌ ์˜ˆ์‹œ์™€ ๋‹ค๋ฅธ ์ ์€ ์ƒ์œ„ ๋ธŒ๋žœ์น˜์—์„œ ํ•˜์œ„ ๋ธŒ๋žœ์น˜๋กœ rebase ํ•œ๋‹ค๋Š” ์ ์ž…๋‹ˆ๋‹ค.)

    (a)     (b)
    * ----- *
             \                    steve/pg
              ----- * ----- *     feature/order 
                    (x)     (y)
    

    ์ž‘์—…์ด ์™„๋ฃŒ๋œ steve/pg ๋ธŒ๋žœ์น˜๋ฅผ ์‚ญ์ œํ•˜์—ฌ ํžˆ์Šคํ† ๋ฆฌ๋ฅผ ๊น”๋”ํ•˜๊ฒŒ ์œ ์ง€ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

  • non-fast-forward๋ฅผ ํ•˜๋ฉด ๋‹ค์Œ๊ณผ ๊ฐ™์Šต๋‹ˆ๋‹ค. (m์€ merge commit)

    [steve/pg] git checkout feature/order
    [feature/order] git merge --no-ff steve/pg

                    (a)     (b)                     (m)
    feature/order   * ----- *                       * -----
                             \                     /
    steve/pg                  ----- * ----- * -----
                                    (x)     (y)
    

    ์ž‘์—…์ด ์™„๋ฃŒ๋œ steve/pg ๋ธŒ๋žœ์น˜๋ฅผ ์‚ญ์ œํ•˜๋ฉด ๋ถ„๊ธฐ๋œ ๋ธŒ๋žœ์น˜์˜ ํ˜•ํƒœ์™€ ๊ทธ ์ปค๋ฐ‹์€ ์œ ์ง€๋˜๊ณ  ๋ธŒ๋žœ์น˜๋งŒ ์‚ญ์ œ๋ฉ๋‹ˆ๋‹ค.

ํ•˜์ง€๋งŒ, feature/order์— ๋ณ€๊ฒฝ์‚ฌํ•ญ์ด ์žˆ๊ณ  rebase ํ•œ ์ ๋„ ์—†๋Š” ๊ฒฝ์šฐ, ์‹ค์งˆ์ ์ธ ๋จธ์ง€ ์ปค๋ฐ‹์œผ๋กœ๋งŒ ๋ณ‘ํ•ฉ์ด ๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค. ์ด ๋•Œ๋Š” non-fast-forward merge์™€ fast-forward merge ๋ชจ๋‘ ๋™์ผํ•˜๊ฒŒ ์ปค๋ฐ‹์ด ๋‚จ๊ฒŒ ๋ฉ๋‹ˆ๋‹ค.

[steve/pg] git checkout feature/order
[feature/order] git merge steve/pg

                  (a)     (b)                     (m)
  feature/order   * ----- *                       * -----
                           \                     /
  steve/pg                  ----- * ----- * -----
                                  (x)     (y)

์ž‘์—…์ด ์™„๋ฃŒ๋œ steve/pg ๋ธŒ๋žœ์น˜๋ฅผ ์‚ญ์ œํ•˜๋ฉด ๋ถ„๊ธฐ๋œ ๋ธŒ๋žœ์น˜์˜ ํ˜•ํƒœ์™€ ๊ทธ ์ปค๋ฐ‹์€ ์œ ์ง€๋˜๊ณ  ๋ธŒ๋žœ์น˜๋งŒ ์‚ญ์ œ๋ฉ๋‹ˆ๋‹ค.

rebase
๋ฆฌ๋ฒ ์ด์Šค๋Š” ๋ณ‘ํ•ฉ(merge)ํ•œ๋‹ค๋Š” ๊ฐœ๋…๊ณผ๋Š” ๊ฑฐ๋ฆฌ๊ฐ€ ์žˆ์ง€๋งŒ, ๋ธŒ๋žœ์น˜์˜ base๋ฅผ ์˜ฎ๊ฒจ ๋‹ค๋ฅธ ๋ธŒ๋žœ์น˜์˜ ๋‚ด์šฉ์„ ๋ฐ˜์˜ํ•œ๋‹ค๋Š” ์ ์—์„œ๋Š” ๋น„์Šทํ•ฉ๋‹ˆ๋‹ค.

rebase ์ž‘์—…์„ ํ•˜๋ฉด์„œ ๊ฐ€์žฅ ์ฃผ์˜ํ•ด์•ผ ํ•  ๊ฒƒ์€ rebase ํ›„์— ๊ทธ rebase๋ฅผ ์ ์šฉ๋ฐ›์€ ์ปค๋ฐ‹๋“ค์€ commit hash๊ฐ€ ๋ฐ”๋€Œ๊ฒŒ ๋ฉ๋‹ˆ๋‹ค. ์ฆ‰, ๊ทธ๋ ‡๊ฒŒ ๋ฐ”๋€ ์ปค๋ฐ‹์ด ์ด๋ฏธ remote(github ๋“ฑ) branch์— ์˜ฌ๋ผ๊ฐ”๋˜ ์ปค๋ฐ‹์ด๋ผ๋ฉด ํ•ด๋‹น ๋‚ด์šฉ์„ (๋ถˆ๊ฐ€ํ”ผํ•˜๊ฒŒ) force-push(--force) ํ•ด์•ผ ํ•  ๊ฒƒ์ด๊ณ , ๋ˆ„๊ตฐ๊ฐ€์™€ ๋™์ผํ•œ ๋ธŒ๋žœ์น˜์—์„œ ํ˜‘์—…์„ ํ•˜๊ณ  ์žˆ๋‹ค๋ฉด ํ‘ธ์‹œ ํ›„ git reset --hard origin/<branch> ๋“ฑ์œผ๋กœ ๋‹ค์‹œ ๋กœ์ปฌ์— ๋ฐ˜์˜์ด ํ•„์š”ํ•  ๊ฒƒ์ž…๋‹ˆ๋‹ค.

๊ฒฐ๋ก ์ ์œผ๋กœ ๊ฐœ์ธ ๋ธŒ๋žœ์น˜์—์„œ๋Š” ๋ฆฌ๋ฒ ์ด์Šค๋ฅผ ์ž์œ ๋กญ๊ฒŒ ํ•ด๋„ ๋ฌด๋ฐฉํ•˜์ง€๋งŒ, ๋‹ค์–‘ํ•œ ํ˜‘์—…๊ณผ ์ปค๋ฐ‹์ด ์งง์€ ์ฃผ๊ธฐ๋กœ ์ด๋ฃจ์–ด์ง„๋‹ค๋ฉด ํ˜‘์—…์— ๋งŽ์€ ์ฃผ์˜๊ฐ€ ํ•„์š”ํ•ฉ๋‹ˆ๋‹ค. ์ด๋ฅผ ์œ„ํ•ด ํ•ญ์ƒ up-stream ์„ค์ •์„ ํ•ด๋‘๊ณ  ๋กœ์ปฌ๊ณผ ๋ฆฌ๋ชจํŠธ์˜ ์ƒํƒœ๋ฅผ ์ตœ์‹ ํ™”ํ•  ํ•„์š”๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค. ์Šต๊ด€์ ์œผ๋กœ git push ์ „์— git fetch์™€ ํ•ด๋‹น ๋ณ€๊ฒฝ์‚ฌํ•ญ์„ ์˜ฌ๋ฐ”๋ฅด๊ฒŒ git pull์„ ํ•ด์ฃผ์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.

rebase๋Š” ๋ณดํ†ต ํ•˜์œ„ ๋ธŒ๋žœ์น˜์—์„œ ์ƒ์œ„ ๋ธŒ๋žœ์น˜๋ฅผ rebaseํ•œ๋‹ค๊ณ  ํ‘œํ˜„ํ•˜๋ฉฐ, ํ˜„์žฌ ๋ธŒ๋žœ์น˜๊ฐ€ "ํ•˜์œ„ ๋ธŒ๋žœ์น˜", ๋ฐ”๋ผ๋ณด๋Š”/๋ณ‘ํ•ฉ ๋ธŒ๋žœ์น˜๊ฐ€ "์ƒ์œ„ ๋ธŒ๋žœ์น˜"๊ฐ€ ๋ฉ๋‹ˆ๋‹ค. ์ƒ์œ„ ๋ธŒ๋žœ์น˜์˜ ๋ณ€๊ฒฝ์‚ฌํ•ญ์„ ๋ชจ๋‘ ๋ฐ˜์˜ํ•˜์—ฌ, ๊ทธ ์ƒ์œ„ ๋ธŒ๋žœ์น˜๋ฅผ ๊ธฐ๋ฐ˜(base)์œผ๋กœ ํ•˜์—ฌ ํ˜„์žฌ ๋ธŒ๋žœ์น˜์˜ base ์ดํ›„ ๋ชจ๋“  ์ปค๋ฐ‹์„ ์ตœ์‹ ํ™”ํ•œ๋‹ค๋Š” ์˜๋ฏธ๋ฅผ ๊ฐ€์ง€๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค.

์˜ˆ๋ฅผ ๋“ค์–ด, ๊ธฐ์กด์˜ ์ƒํƒœ๊ฐ€ ๋‹ค์Œ๊ณผ ๊ฐ™๋‹ค๋ฉด,

                (a)     (b)
feature/order   * ----- *
                         \
steve/pg                  ----- * ----- *
                                (x)     (y)

steve/pg์—์„œ feature/order ๊ธฐ์ค€์œผ๋กœ rebaseํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

[steve/pg] git rebase feature/order
f/o๊ฐ€ feature/order, s/p๊ฐ€ steve/pg ๋ธŒ๋žœ์น˜.

 (a)    (b)     (x)     (y)
* ----- * ----- * ----- *
        (f/o)           (s/p)

์ด๋•Œ, steve/pg์—์„œ ์ปค๋ฐ‹ํ–ˆ๋˜ (x), (y) ์ปค๋ฐ‹์ด ์˜ํ–ฅ์„ ๋ฐ›์Šต๋‹ˆ๋‹ค. ์ด๋ฏธ remote์— ์˜ฌ๋ผ๊ฐ”๋‹ค๋ฉด force push๋กœ ์—…๋ฐ์ดํŠธํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.

๋งŒ์•ฝ rebase์—์„œ conflict๊ฐ€ ๋‚œ ๊ฒฝ์šฐ, ๊ฐ ํŒŒ์ผ์—์„œ conflict๋ฅผ ํ•ด๊ฒฐํ•˜๊ณ  rebase๋ฅผ ์ง„ํ–‰ํ•˜๋ฉด ๋ฉ๋‹ˆ๋‹ค. rebase๋Š” ์ง„ํ–‰ ๋ฐฉ๋ฒ•์ด ํ˜„์žฌ ๋ธŒ๋žœ์น˜์˜ ์ปค๋ฐ‹์„ ํ•˜๋‚˜ํ•˜๋‚˜ ํƒ์ƒ‰ํ•˜๋ฉฐ, ์ ์šฉํ•˜๋Š” ๋ฐฉ๋ฒ•์ด๋ฏ€๋กœ, ํ•œ ๋ฒˆ rebase๋ฅผ ํ•  ๋•Œ ๊ฐ ์ปค๋ฐ‹๋ณ„๋กœ ์—ฌ๋Ÿฌ๋ฒˆ ํ•ด๊ฒฐํ•ด์•ผ ํ•˜๋Š” ๊ฒฝ์šฐ๋„ ์žˆ์Šต๋‹ˆ๋‹ค. ๋Œ€์‹  ์ด์™€ ๊ฐ™์ด conflict๋ฅผ ํ•ด๊ฒฐํ•˜๋Š” ๊ฒƒ์ด ๊ณต๋™์ž‘์—… ์—…๋ฌด์—์„œ๋„ ๋ฌธ์ œ์—†์ด ์š”๊ตฌ์‚ฌํ•ญ์„ ์˜ฌ๋ฐ”๋ฅด๊ฒŒ ๋ฐ˜์˜ํ•  ์ˆ˜ ์žˆ๋Š” ๋ฐฉ๋ฒ•์ž…๋‹ˆ๋‹ค.

[steve/pg] git rebase feature/order
[steve/pg] [CONFLICT ๋ฐœ์ƒ]
[steve/pg] git add [confilcted file]
[steve/pg] git rebase --continue

3. Issue

์ƒ๋‹จ์œผ๋กœ โฌ†๏ธ

์—ฌ๊ธฐ๋ถ€ํ„ฐ 6. Wiki๊นŒ์ง€๋Š” GitHub ์œ„์ฃผ์˜ ๋‚ด์šฉ์ด์ง€๋งŒ, 3. Issue์™€ 4. Pull Request๋Š” ๋‹ค๋ฅธ git hosting service(bitbucket, gitlab ๋“ฑ)์—์„œ๋„ ์‚ฌ์šฉ๋˜๋Š” ๊ฒƒ์œผ๋กœ ๊ธฐ๋ณธ์ ์ธ ๊ฐœ๋…์€ ๋™์ผํ•ฉ๋‹ˆ๋‹ค. ๊ทธ๋Ÿฌ๋‚˜ ์—ฌ๊ธฐ์„œ๋Š” github ํ™˜๊ฒฝ์„ ์œ„์ฃผ๋กœ ์„ค๋ช…ํ•ฉ๋‹ˆ๋‹ค.

Issue๋กœ ๋“ฑ๋ก๋˜๋Š” ๊ฒฝ์šฐ์—๋Š” ๋‹ค์–‘ํ•œ ๊ฒฝ์šฐ๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค. jira์˜ ticket์ฒ˜๋Ÿผ ์‚ฌ์šฉํ•  ์ˆ˜๋„ ์žˆ๊ณ , ๋ฒ„๊ทธ ํ”ฝ์Šค๋ฅผ ์š”๊ตฌํ•˜๋Š” issue๊ฐ€ ๋“ฑ๋ก๋  ์ˆ˜๋„ ์žˆ์Šต๋‹ˆ๋‹ค. ํŠนํžˆ ์˜คํ”ˆ์†Œ์Šค๋ผ๋ฉด ๋‹ค์–‘ํ•œ ๋‚ด์šฉ์ด ์ด์Šˆ๋กœ ๋“ฑ๋ก๋  ์ˆ˜ ์žˆ๊ณ , ์‚ฌ๋‚ด ํ”„๋กœ์ ํŠธ์—์„œ๋„ ์šฉ๋„๊ฐ€ ๋‹ค์–‘ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์ด ์„น์…˜์˜ ๋ชฉํ‘œ๋Š” ๋‹จ์ˆœํžˆ ์ด์Šˆ ํ•˜๋‚˜๋ฅผ ๋งŒ๋“ค๊ณ , ๋ฐœํ–‰ํ•˜๋Š” ๊ฒƒ์ด ์•„๋‹ˆ๋ผ, github์˜ ๋‹ค์–‘ํ•œ ๊ธฐ๋Šฅ๋“ค์„ ์ด์šฉํ•˜์—ฌ ์ข€ ๋” ์ƒ์‚ฐ์„ฑ ๋†’๊ฒŒ Issue๋ฅผ ๋‹ค๋ฃจ๋Š” ๋ฐฉ๋ฒ•์„ ์•ˆ๋‚ดํ•ฉ๋‹ˆ๋‹ค.

3.1. Issue Template

4. Pull Request

์ƒ๋‹จ์œผ๋กœ โฌ†๏ธ

5. Actions

์ƒ๋‹จ์œผ๋กœ โฌ†๏ธ

6. Wiki

์ƒ๋‹จ์œผ๋กœ โฌ†๏ธ

7. Troubleshooting

์ƒ๋‹จ์œผ๋กœ โฌ†๏ธ

8. Tips

์ƒ๋‹จ์œผ๋กœ โฌ†๏ธ

9. So, What should I do?

์ƒ๋‹จ์œผ๋กœ โฌ†๏ธ

git(ํ˜น์€ github)์€ ์‚ฌ์šฉํ•˜๋Š” ์‚ฌ๋žŒ, ํ˜น์€ ์กฐ์ง์— ๋”ฐ๋ผ ๋งค์šฐ ์œ ์—ฐํ•˜๊ฒŒ ์‚ฌ์šฉ๋˜์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. ์กฐ์ง์ด๋ผ๋ฉด, ๊ฐœ๋ฐœ ์กฐ์ง๋‚ด ์ธ์› ๋ชจ๋‘๊ฐ€ git๊ณผ gitflow์— ๋Œ€ํ•œ ์ดํ•ด๊ฐ€ ๋˜์–ด ์žˆ์„ ๋•Œ, ์ œ๋Œ€๋กœ ์ž‘๋™ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

Reference

License

MIT

Author

stevejkang iam@juneyoung.io

About

๐Ÿ“ [WIP] Personal git/github guideline about commit convention, git-flow, issue/pull-request templates, etc.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published