git-guideline
git-guideline copied to clipboard
๐ [WIP] Personal git/github guideline about commit convention, git-flow, issue/pull-request templates, etc.
git-guideline
Personal git/github guideline about commit convention, git flow, issue/pull-request templates, etc.
Table of Contents
- Commit Convention
- Git Flow & Branch
- Issue
- Pull Request
- Actions
- Wiki
- Troubleshooting
- Tips
- ์ด์ ๋ญํ๋ฉด ๋๋์?
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 ์ ๋ฆฌ
- Fix [๊ธฐ๋ฅ์์ ]
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
- ์ข์ git commit ๋ฉ์์ง๋ฅผ ์ํ ์์ด ์ฌ์
- GIT์ ๊ธฐ๋ฐ์ผ๋ก ํ ํ๋ก์ ํธ ๊ฐ๋ฐํ๋ก์ธ์ค
- A successful Git branching model
- Merge Branch - Backlog
- Rebase Branch - Backlog
License
MIT
Author
stevejkang [email protected]
