GitHub ํ์
GitHub ํ์ ¶
1. ํ์ ์ํฌํ๋ก์ฐ ๊ฐ์¶
GitHub์์ ํ์ ํ๋ ๋ ๊ฐ์ง ์ฃผ์ ๋ฐฉ์:
| ๋ฐฉ์ | ์ค๋ช | ์ฌ์ฉ ๊ฒฝ์ฐ |
|---|---|---|
| Collaborator | ์ ์ฅ์์ ์ง์ ํธ์ ๊ถํ | ํ ํ๋ก์ ํธ |
| Fork & PR | ๋ณต์ ํ Pull Request | ์คํ์์ค ๊ธฐ์ฌ |
2. Fork (ํฌํฌ)¶
๋ค๋ฅธ ์ฌ๋์ ์ ์ฅ์๋ฅผ ๋ด ๊ณ์ ์ผ๋ก ๋ณต์ฌํฉ๋๋ค.
Fork ํ๋ ๋ฐฉ๋ฒ¶
- ์๋ณธ ์ ์ฅ์ ํ์ด์ง ๋ฐฉ๋ฌธ
- ์ฐ์ธก ์๋จ "Fork" ๋ฒํผ ํด๋ฆญ
- ๋ด ๊ณ์ ์ผ๋ก ๋ณต์ฌ๋จ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ โ
โ ์๋ณธ: octocat/hello-world โ
โ โ โ
โ โ Fork โ
โ โผ โ
โ ๋ด ๊ณ์ : myname/hello-world โ ๋
๋ฆฝ์ ์ธ ๋ณต์ฌ๋ณธ โ
โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Fork ํ ์์ ํ๋ฆ¶
# 1. Forkํ ์ ์ฅ์ ํด๋ก
git clone git@github.com:myname/hello-world.git
cd hello-world
# 2. ์๋ณธ ์ ์ฅ์๋ฅผ upstream์ผ๋ก ์ถ๊ฐ
git remote add upstream git@github.com:octocat/hello-world.git
# 3. remote ํ์ธ
git remote -v
# origin git@github.com:myname/hello-world.git (fetch)
# origin git@github.com:myname/hello-world.git (push)
# upstream git@github.com:octocat/hello-world.git (fetch)
# upstream git@github.com:octocat/hello-world.git (push)
์๋ณธ ์ ์ฅ์์ ๋๊ธฐํ¶
# 1. ์๋ณธ์ ์ต์ ๋ณ๊ฒฝ ๊ฐ์ ธ์ค๊ธฐ
git fetch upstream
# 2. main ๋ธ๋์น์ ๋ณํฉ
git switch main
git merge upstream/main
# 3. ๋ด Fork์ ๋ฐ์
git push origin main
3. Pull Request (PR)¶
๋ณ๊ฒฝ ์ฌํญ์ ์๋ณธ ์ ์ฅ์์ ๋ฐ์ํด๋ฌ๋ผ๊ณ ์์ฒญํฉ๋๋ค.
Pull Request ์์ฑ ๊ณผ์ ¶
# 1. ์ ๋ธ๋์น์์ ์์
git switch -c feature/add-greeting
# 2. ๋ณ๊ฒฝ ํ ์ปค๋ฐ
echo "Hello, World!" > greeting.txt
git add .
git commit -m "feat: ์ธ์ฌ๋ง ํ์ผ ์ถ๊ฐ"
# 3. ๋ด Fork์ ํธ์
git push origin feature/add-greeting
GitHub์์ PR ์์ฑ¶
- GitHub์์ "Compare & pull request" ๋ฒํผ ํด๋ฆญ
- PR ์ ๋ณด ์์ฑ:
- ์ ๋ชฉ: ๋ณ๊ฒฝ ์ฌํญ ์์ฝ
- ์ค๋ช : ์์ธ ๋ด์ฉ, ๊ด๋ จ ์ด์
- "Create pull request" ํด๋ฆญ
PR ํ ํ๋ฆฟ ์์¶
## ๋ณ๊ฒฝ ์ฌํญ
- ์ธ์ฌ๋ง ์ถ๋ ฅ ๊ธฐ๋ฅ ์ถ๊ฐ
- greeting.txt ํ์ผ ์์ฑ
## ๊ด๋ จ ์ด์
Closes #123
## ํ
์คํธ
- [x] ๋ก์ปฌ์์ ๋์ ํ์ธ
- [x] ๊ธฐ์กด ๊ธฐ๋ฅ์ ์ํฅ ์์
## ์คํฌ๋ฆฐ์ท
(ํ์์ ์ฒจ๋ถ)
PR ์ํฌํ๋ก์ฐ¶
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ โ
โ 1. Fork & Clone โ
โ โ โ
โ 2. ๋ธ๋์น ์์ฑ & ์์
โ
โ โ โ
โ 3. Push to Fork โ
โ โ โ
โ 4. Create Pull Request โ
โ โ โ
โ 5. Code Review (๋ฆฌ๋ทฐ์ด ํผ๋๋ฐฑ) โ
โ โ โ
โ 6. ์์ ํ์์ ์ถ๊ฐ ์ปค๋ฐ โ
โ โ โ
โ 7. Merge (๊ด๋ฆฌ์๊ฐ ๋ณํฉ) โ
โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
4. Code Review (์ฝ๋ ๋ฆฌ๋ทฐ)¶
PR์ ํตํด ์ฝ๋๋ฅผ ๊ฒํ ํ๊ณ ํผ๋๋ฐฑ์ ์ฃผ๊ณ ๋ฐ์ต๋๋ค.
๋ฆฌ๋ทฐ ์์ฒญํ๊ธฐ¶
- PR ํ์ด์ง์์ "Reviewers" ํด๋ฆญ
- ๋ฆฌ๋ทฐ์ด ์ ํ
๋ฆฌ๋ทฐ ์์ฑํ๊ธฐ¶
- "Files changed" ํญ์์ ๋ณ๊ฒฝ ๋ด์ฉ ํ์ธ
- ๋ผ์ธ๋ณ๋ก ์ฝ๋ฉํธ ์ถ๊ฐ ๊ฐ๋ฅ
- ๋ฆฌ๋ทฐ ์๋ฃ:
- Comment: ์ผ๋ฐ ์ฝ๋ฉํธ
- Approve: ์น์ธ
- Request changes: ์์ ์์ฒญ
๋ฆฌ๋ทฐ ํผ๋๋ฐฑ ๋ฐ์¶
# ํผ๋๋ฐฑ ๋ฐ์ ๋ด์ฉ ์์
git add .
git commit -m "fix: ๋ฆฌ๋ทฐ ํผ๋๋ฐฑ ๋ฐ์"
git push origin feature/add-greeting
# PR์ ์๋์ผ๋ก ์ปค๋ฐ ์ถ๊ฐ๋จ
5. Issues (์ด์)¶
๋ฒ๊ทธ, ๊ธฐ๋ฅ ์์ฒญ, ์ง๋ฌธ ๋ฑ์ ๊ด๋ฆฌํฉ๋๋ค.
Issue ์์ฑ¶
- ์ ์ฅ์์ "Issues" ํญ
- "New issue" ํด๋ฆญ
- ์ ๋ชฉ๊ณผ ์ค๋ช ์์ฑ
Issue ํ ํ๋ฆฟ ์์¶
๋ฒ๊ทธ ๋ฆฌํฌํธ:
## ๋ฒ๊ทธ ์ค๋ช
๋ก๊ทธ์ธ ๋ฒํผ ํด๋ฆญ ์ ์๋ฌ ๋ฐ์
## ์ฌํ ๋ฐฉ๋ฒ
1. ๋ก๊ทธ์ธ ํ์ด์ง ์ด๋
2. ์ด๋ฉ์ผ/๋น๋ฐ๋ฒํธ ์
๋ ฅ
3. ๋ก๊ทธ์ธ ๋ฒํผ ํด๋ฆญ
4. ์๋ฌ ๋ฉ์์ง ํ์ธ
## ์์ ๋์
๋ฉ์ธ ํ์ด์ง๋ก ์ด๋
## ํ๊ฒฝ
- OS: macOS 14.0
- Browser: Chrome 120
๊ธฐ๋ฅ ์์ฒญ:
## ๊ธฐ๋ฅ ์ค๋ช
๋คํฌ ๋ชจ๋ ์ง์
## ํ์ํ ์ด์
๋์ ํผ๋ก ๊ฐ์
## ์ถ๊ฐ ์ ๋ณด
(๋์์ธ ์ฐธ๊ณ ์๋ฃ ๋ฑ)
Issue์ PR ์ฐ๊ฒฐ¶
# PR ์ค๋ช
์์ ์ด์ ์ฐธ์กฐ
Fixes #42
Closes #42
Resolves #42
# ์ ํค์๋ ์ฌ์ฉ ์ PR ๋จธ์ง๋๋ฉด ์ด์ ์๋ ์ข
๋ฃ
6. GitHub ํ์ ์ค์ต¶
์ค์ต 1: ์คํ์์ค ๊ธฐ์ฌ ์๋ฎฌ๋ ์ด์ ¶
# 1. ์ฐ์ต์ฉ ์ ์ฅ์ Fork (GitHub ์น์์)
# https://github.com/octocat/Spoon-Knife
# 2. Forkํ ์ ์ฅ์ ํด๋ก
git clone git@github.com:myname/Spoon-Knife.git
cd Spoon-Knife
# 3. upstream ์ค์
git remote add upstream git@github.com:octocat/Spoon-Knife.git
# 4. ๋ธ๋์น ์์ฑ
git switch -c my-contribution
# 5. ํ์ผ ์์
echo "My name is here!" >> contributors.txt
# 6. ์ปค๋ฐ & ํธ์
git add .
git commit -m "Add my name to contributors"
git push origin my-contribution
# 7. GitHub์์ Pull Request ์์ฑ
์ค์ต 2: ํ ํ์ ์๋๋ฆฌ์ค¶
# === ํ์ A (์ ์ฅ์ ๊ด๋ฆฌ์) ===
# 1. ์ ์ฅ์ ์์ฑ ๋ฐ ์ด๊ธฐ ์ค์
mkdir team-project
cd team-project
git init
echo "# Team Project" > README.md
git add .
git commit -m "initial commit"
git remote add origin git@github.com:teamA/team-project.git
git push -u origin main
# 2. Collaborator ์ถ๊ฐ (GitHub Settings > Collaborators)
# === ํ์ B ===
# 1. ์ ์ฅ์ ํด๋ก
git clone git@github.com:teamA/team-project.git
cd team-project
# 2. ๋ธ๋์น์์ ์์
git switch -c feature/login
echo "login feature" > login.js
git add .
git commit -m "feat: ๋ก๊ทธ์ธ ๊ธฐ๋ฅ ๊ตฌํ"
git push origin feature/login
# 3. GitHub์์ PR ์์ฑ
# === ํ์ A ===
# 1. PR ๋ฆฌ๋ทฐ ๋ฐ ๋จธ์ง
# 2. ๋จธ์ง ํ ๋ก์ปฌ ์
๋ฐ์ดํธ
git pull origin main
7. ์ ์ฉํ GitHub ๊ธฐ๋ฅ¶
Labels (๋ผ๋ฒจ)¶
์ด์/PR ๋ถ๋ฅ:
- bug: ๋ฒ๊ทธ
- enhancement: ๊ธฐ๋ฅ ๊ฐ์
- documentation: ๋ฌธ์
- good first issue: ์
๋ฌธ์์ฉ
Milestones (๋ง์ผ์คํค)¶
์ด์๋ค์ ๋ฒ์ /์คํ๋ฆฐํธ๋ก ๊ทธ๋ฃนํ
Projects (ํ๋ก์ ํธ ๋ณด๋)¶
์นธ๋ฐ ๋ณด๋ ์คํ์ผ๋ก ์์ ๊ด๋ฆฌ: - To Do - In Progress - Done
GitHub Actions¶
์๋ํ ์ํฌํ๋ก์ฐ:
# .github/workflows/ci.yml
name: CI
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Run tests
run: npm test
๋ช ๋ น์ด ์์ฝ¶
| ๋ช ๋ น์ด | ์ค๋ช |
|---|---|
git remote add upstream URL |
์๋ณธ ์ ์ฅ์ ์ถ๊ฐ |
git fetch upstream |
์๋ณธ ๋ณ๊ฒฝ ๊ฐ์ ธ์ค๊ธฐ |
git merge upstream/main |
์๋ณธ๊ณผ ๋ณํฉ |
git push origin ๋ธ๋์น |
Fork์ ํธ์ |
ํต์ฌ ์ฉ์ด ์ ๋ฆฌ¶
| ์ฉ์ด | ์ค๋ช |
|---|---|
| Fork | ์ ์ฅ์๋ฅผ ๋ด ๊ณ์ ์ผ๋ก ๋ณต์ฌ |
| Pull Request | ๋ณ๊ฒฝ ์ฌํญ ๋ฐ์ ์์ฒญ |
| Code Review | ์ฝ๋ ๊ฒํ |
| Merge | ๋ธ๋์น/PR ๋ณํฉ |
| Issue | ๋ฒ๊ทธ/๊ธฐ๋ฅ ์์ฒญ ๊ด๋ฆฌ |
| upstream | ์๋ณธ ์ ์ฅ์ |
| origin | ๋ด ์๊ฒฉ ์ ์ฅ์ |
ํ์ต ์๋ฃ!¶
Git/GitHub ๊ธฐ์ด ํ์ต์ ์๋ฃํ์ต๋๋ค. ๋ค์ ์ฃผ์ ๋ก ๋์ด๊ฐ๊ธฐ ์ ์ ์ค์ ํ๋ก์ ํธ์์ ์ฐ์ตํด๋ณด์ธ์!
์ถ์ฒ ์ฐ์ต¶
- GitHub์์ ๊ด์ฌ ์๋ ์คํ์์ค ํ๋ก์ ํธ ์ฐพ๊ธฐ
- ๋ฌธ์ ์คํ ์์ ์ผ๋ก ์ฒซ ๊ธฐ์ฌ ์๋
- ๊ฐ์ธ ํ๋ก์ ํธ๋ฅผ GitHub์ ์ฌ๋ฆฌ๊ณ ๊ด๋ฆฌ