← 가이드 목록으로 ← Back to guides

Git 버전 관리 완벽 가이드 Complete Guide to Git Version Control

Git은 가장 널리 사용되는 분산 버전 관리 시스템입니다. 코드의 변경 이력을 추적하고, 팀원들과 효율적으로 협업할 수 있게 해줍니다.

Git is the most widely used distributed version control system. It tracks code changes and enables efficient collaboration with team members.

기본 명령어 Basic Commands

# 저장소 초기화
git init

# 저장소 복제
git clone https://github.com/user/repo.git

# 변경사항 확인
git status
git diff

# 스테이징 및 커밋
git add .
git commit -m "commit message"
# Initialize repository
git init

# Clone repository
git clone https://github.com/user/repo.git

# Check changes
git status
git diff

# Stage and commit
git add .
git commit -m "commit message"

브랜치 관리 Branch Management

브랜치를 사용하면 독립적인 개발 라인을 만들어 기능을 개발하거나 버그를 수정할 수 있습니다.

Branches allow you to create independent development lines for features or bug fixes.

# 브랜치 생성 및 전환
git branch feature/login
git checkout feature/login

# 한 번에 생성 및 전환
git checkout -b feature/signup

# 브랜치 병합
git checkout main
git merge feature/login

# 브랜치 삭제
git branch -d feature/login
# Create and switch branch
git branch feature/login
git checkout feature/login

# Create and switch in one command
git checkout -b feature/signup

# Merge branch
git checkout main
git merge feature/login

# Delete branch
git branch -d feature/login

원격 저장소 작업 Working with Remotes

# 원격 저장소 연결
git remote add origin https://github.com/user/repo.git

# 변경사항 가져오기
git fetch origin
git pull origin main

# 변경사항 푸시
git push origin main
git push -u origin feature/new-feature
# Connect remote repository
git remote add origin https://github.com/user/repo.git

# Fetch changes
git fetch origin
git pull origin main

# Push changes
git push origin main
git push -u origin feature/new-feature

실수 되돌리기 Undoing Mistakes

# 작업 디렉토리 변경사항 취소
git restore filename.js

# 스테이징 취소
git restore --staged filename.js

# 마지막 커밋 취소 (변경사항 유지)
git reset HEAD~1

# 마지막 커밋 취소 (변경사항 삭제)
git reset --hard HEAD~1
# Discard working directory changes
git restore filename.js

# Unstage changes
git restore --staged filename.js

# Undo last commit (keep changes)
git reset HEAD~1

# Undo last commit (discard changes)
git reset --hard HEAD~1

💡 Git 타자 연습의 장점 💡 Benefits of Git Typing Practice

Git 명령어를 빠르게 타이핑할 수 있으면 터미널에서의 작업 속도가 크게 향상됩니다. 특히 git checkout -b, git push -u origin 같은 조합을 손에 익히세요.

Fast Git command typing significantly improves terminal workflow speed. Focus on combinations like git checkout -b and git push -u origin.