nugawiki

./categories/dev-ops

Git CLI 명령어 #1

업데이트 2026-07-21 조회수

status

  • git status — Untracked / Staged / Modified / clean

log

git config --global alias.lg "log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)' --all"
git lg

add / commit

git add <파일>
git commit -am "메시지"     # add+commit (modified만)
git commit --amend          # 마지막 커밋 수정

branch

git br                                # 목록 (* = 현재)
git br -r                             # 원격
git br {브랜치명}                     # 생성
git br -D {브랜치명}                  # 강제 삭제
git br -d {브랜치명}                  # merge된 것만 삭제
git push origin --delete {브랜치명}   # 원격 삭제
git fetch -p                          # 삭제된 원격 반영

checkout

git checkout {브랜치명}
git checkout {커밋해시}     # working tree clean 필요
git checkout -b {브랜치명}  # 생성+이동

push

git push [원격저장소] [브랜치]
git push -f                                    # 강제(혼자 쓰는 브랜치만)
git push --set-upstream [원격저장소] [브랜치]  # no upstream 시

pull / fetch

  • git pull — fetch + merge (충돌 시 실패)
  • git fetch — 데이터만 (merge 없음)
  • 충돌: git merge --abort 또는 수정 → addcommitpush

./comments