C.W.K.
Stream
Lesson 02 of 05 · published

pull은 fetch + integration

~20 min · pull, merge, rebase

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

git pull 은 한 작업이 아니라 둘

git pullgit fetch + 통합 단계의 줄임말 — 기본은 merge, 선택적으로 rebase. 그 두 번째 단계가 혼란의 소굴이야. 의식 없이 git pull 하면 발산이 있을 때 local branch 에 merge commit 을 만들어 — 짧은 feature 작업엔 거의 원하는 결과가 아니야.

통합 선택 둘, 둘 다 정당해. Merge 는 필요하면 merge commit 만들어서 upstream 변경과 합쳐. history 에 발산 보존. 발산이 의미 있을 때 좋음 (장기 integration branch, release). Rebase 는 local commit 을 upstream tip 위에 다시 replay. 결과: 선형 history. 발산이 '나 작업, 동시에 누군가도 작업' 인 짧은 feature 에 좋음.

현대적 권장 default: global 에 pull.rebase = true, daily 엔 plain git pull. 선형 history 가 읽기 편하고, bisect 깨끗하고, reviewer 가 'feature 에 main merge' noise 가 아닌 한 줄 chain 봐. 진짜 merge 가 필요하면 (release branch 통합, 큰 기능 handoff) 명시적 git merge 사용. git pull 은 일상 케이스용.

알아둘 실패 모드 둘. Uncommitted 변경 + pull: 통합이 같은 파일 건드리면 Git 거부. 해결: commit (또는 stash) 먼저, pull 다음. Pull rebase 중 conflict: rebase 가 충돌 commit 마다 멈추고 해결 후 git rebase --continue 요구. rebase pull 이 옆길로 새면 git rebase --abort 가 pull 전으로 rewind, 완전 가역.

Code

Daily-grade pull 패턴·bash
# 한 번 설정, 잊어:
git config --global pull.rebase true
git config --global rebase.autoStash true   # dirty tree 자동 stash

# feature branch 일상 pull:
git pull           # 위 global 설정과 함께 = fetch + rebase

# 일회성 merge pull (rebase default 오버라이드):
git pull --no-rebase

# fetch 만 + 통합 안 하고 수동 선택:
git fetch
git rebase origin/main      # 또는 git merge origin/main
Pull 이 꼬일 때·bash
# pull 전에 dirty tree?
git stash push -u -m "pre-pull WIP"
git pull
git stash pop      # 또는 git stash apply

# rebase pull 중 conflict:
# 충돌 파일 편집 후:
git add resolved-file
git rebase --continue
# ... 또는 통째로 빠지기:
git rebase --abort

# 헷갈린 merge pull 후 undo:
git reset --merge ORIG_HEAD

External links

Exercise

실제 repo 에서 global 에 pull.rebase = true + rebase.autoStash = true 박아. 발산 만들기: local commit, 다른 clone 에서 push (또는 remote-tracking ref 편집으로 시뮬레이션), 그 다음 원본에서 git pull. git log --oneline --graph 로 선형 history 확인. reset, 그 repo 에 pull.rebase = false 설정, 발산 반복, pull, merge commit 관찰. 작업의 어떤 branch 종류에 어떤 정책이 맞는지 결정.

Progress

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

댓글 0

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

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