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

git status: 움직이기 전에 읽어

~14 min · status, inspection

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

git status 가 먼저 읽는 dashboard

진지한 workflow 에서 가장 많이 치는 Git 명령은 git status 야. 자주 쳐 — stage 전, 편집 후, 어디까지 했는지 까먹었을 때, 뭔가 이상할 때. 세 영역 진실을 한 번에 알려주는 dashboard 야: 뭐가 staged, 뭐가 수정됐지만 staged 아닌지, 뭐가 untracked, 어떤 branch 인지, remote 보다 얼마나 앞서거나 뒤졌는지.

기본 git status 출력은 친절하고 verbose — 배울 땐 좋아. short 버전 git status -s 는 파일당 두 글자 열 두 개. 왼쪽 = index 상태. 오른쪽 = working-tree 상태. M_ 은 staged modification + 추가 변경 없음. _M 은 modified 인데 stage 안 됨. MM 은 staged 됐고 그 후 또 modified (commit 하면 옛 version 들어감). A_ 는 staged new file. ?? 는 untracked. 이 글자들 익숙해지면 status 가 한 문단이 아니라 한 눈에 들어와.

daily 용으로 status 를 업그레이드하는 flag 두 개. --branch (or -b) 는 현재 branch 와 upstream 비교를 보여줘. --ahead-behind 는 default 로 켜져 있어. 팀 workflow 에선 "Your branch is ahead of 'origin/main' by 2 commits" 같은 줄을 자주 봐 — push 하라는 dashboard 신호야. git status --short --branch 함께가 muscle memory 에 추천 mode.

숨은 함정: git status 는 다른 branch 에만 있는 commit 은 말 안 해. uncommitted 작업 둔 채 feature branch 에서 떠나서 main 에서 status 했으면 깨끗해 보여. 작업은 멀쩡해 — 다른 branch 위에 있어 — 근데 dashboard 가 경고 안 해. multi-branch 시야가 필요하면 git branch -vv.

Code

Daily-loop status 습관·bash
git status -sb
# 출력 범례:
#   ## main...origin/main [ahead 1]   <- branch + upstream 관계
#    M src/app.js                     <- modified, stage 안 됨
#   M  src/style.css                  <- staged modification
#   MM src/index.html                 <- staged 됐고 또 modified (위험)
#   A  src/new.js                     <- staged new file
#   ?? notes.txt                      <- untracked
다른 branch 에 숨은 작업 찾기·bash
# upstream + ahead/behind + 마지막 commit 요약 포함 branch list:
git branch -vv

# 예시 출력:
#   feature/login   abc1234 [origin/feature/login: ahead 3] Add OAuth flow
# * main            def5678 [origin/main]                   Merge feature/x

External links

Exercise

활성 프로젝트 열어. 수정 세 개 만들어: 하나는 stage, 하나는 stage 후 다시 수정, 마지막은 unstaged. git status -sb 돌리고 각 파일의 두 글자 코드를 읽어. 문서 보기 전에 각 M, blank, ? 가 뭘 뜻하는지 먼저 추측. git diff + git diff --staged 로 검증. 의외였던 조합 하나 적어.

Progress

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

댓글 0

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

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