본문 바로가기
C.W.K.
Stream
Lesson 04 of 05 · published

Fork와 Pull Request

~22 min · github, pr, fork

Level 0추적 전 새싹
0 XP0/47 lessons0/14 achievements
0/100 XP to next level100 XP to go0% complete

Fork는 협업을 직접 push가 아니라 요청으로 바꿔

Fork-and-pull 방식은 쓰기 권한이 없는 프로젝트에 기여하는 오픈소스의 기본 흐름이야. 프로젝트를 네 계정으로 fork하고, fork의 branch에서 변경한 뒤, Pull Request로 원본 maintainer에게 가져가 달라고 요청해. 원본 repo에 push 권한을 줄 필요가 없어. PR이 직접 push를 대신하는 요청과 검토의 통로가 되니까.

GitHub의 "Fork" 버튼은 네 계정에 server-side 사본을 만들어. 그 fork를 로컬로 clone하고 원본을 두 번째 remote, 관습적으로 upstream으로 추가해. 이후에는 upstream을 fetch하고 fork의 main을 맞춘 뒤, 작업 branch를 갈라 fork에 push하고 GitHub에서 PR을 열어. PR description에는 무엇을 왜 바꿨는지, 어떻게 검증하는지, 어떤 위험이 있는지를 적어.

Fork를 원본과 맞춰두는 일도 중요해. 너무 오래된 base에서 만든 PR은 불필요한 conflict를 만들거든. git fetch upstream, git switch main, git rebase upstream/main, git push origin main 순서로 움직이면 fork의 main이 원본을 비춰. 이때 main에서 branch를 만들면 깔끔하게 적용되는 PR이 돼. GitHub web의 'Sync fork' 버튼도 같은 일을 해.

PR 자체도 협업 산출물이야. 제목은 명령형으로 쓰고 가능하다면 Conventional Commits prefix를 붙여. description에는 what, why, how to test를 구획으로 나누고, 시각적 변경이면 screenshot을, breaking change면 명시적인 경고를 넣어. issue도 연결해. 한 PR에는 한 관심사만 담아. 검토자가 comment하면 같은 branch에 commit을 더 push해 PR을 갱신하고, 승인 뒤 maintainer가 merge하면 양쪽 branch를 정리해.

Code

Fork-clone-branch-PR 사이클·bash
# 1. GitHub 에서 Fork (브라우저), 네 fork clone:
git clone git@github.com:YOU/repo.git
cd repo

# 2. 원본을 upstream 으로 추가:
git remote add upstream https://github.com/ORIGINAL/repo.git
git remote -v
# origin    git@github.com:YOU/repo.git
# upstream  https://github.com/ORIGINAL/repo.git

# 3. 최신 upstream main 에서 분기:
git fetch upstream
git switch -c fix/typo-readme upstream/main

# 4. 편집, commit, 네 fork 로 push:
git add README.md
git commit -m "docs: fix install command typo"
git push -u origin fix/typo-readme

# 5. GitHub 에서 YOU:fix/typo-readme → ORIGINAL:main 로 PR 열기
Fork main 동기화 유지·bash
git fetch upstream
git switch main
git rebase upstream/main      # 또는 merge — 프로젝트 정책 따름
git push origin main          # GitHub 의 fork main 동기화

# main 에서 새 branch 시작 전마다 반복

External links

Exercise

GitHub에서 작은 오픈소스 프로젝트를 fork해. fork를 clone하고 upstream을 추가한 뒤 main을 동기화해. 오타나 README 보완 같은 작은 문서 변경을 위한 branch를 만들고 fork로 push해 PR을 열어. template을 따라 what, why, how-to-verify 구획이 있는 제대로 된 description을 작성해. 실제로 merge하지 않아도 괜찮아. 전체 흐름을 끝까지 관찰하는 게 목적이야.

Progress

Progress is local-only — sign in to sync across devices.
이 페이지에서 버그를 발견하셨거나 피드백이 있으세요?문제 신고

댓글 0

🔔 답글 알림 (로그인 필요)
로그인댓글을 남기려면 로그인해 주세요.

아직 댓글이 없어요. 첫 댓글을 남겨보세요.