Git 명령어 모음 (with .gitignore)

Cafelatte·2025년 1월 6일

Engineering

목록 보기
2/5

git 명령어 모음

# main 레포지토리를 디렉토리에 다운로드
git clone [URL]

# 특정 branch 레포지토리를 디렉토리에 다운로드
git clone -b [branch] [URL]

# 현재 디렉토리를 레포지토리에 연결 
git remote add origin [URL]

# 연결된 레포지토리 삭제
git remote remove origin

# 브렌치 정보 및 현재 디렉토리 파일 확인
git status

# 브렌치 변경 (switch 권장)
git switch [branch]
git checkout [branch]

# 브렌치 생성
git checkout -b [branch]

# 로컬 브렌치 삭제 (-D일 경우 강제삭제)
git branch -d [branch]
git branch -D [branch]

# 레포지토리 브렌치 삭제
git push origin --delete [branch]

# 레포지토리 pull
git pull origin [branch]

# 변경 내용 모두 추가
git add .

# 변경 내용 커밋
git commit
git commit -m [message]

# 레포지토리 push
git push origin [branch]

# cache 초기화
git rm -r --cached .

# 최초 로그인 후 [seconds]초 동안 로그인 유지
git config --global credential.helper 'cache --timeout=[seconds]'

# 브렌치 정보 업데이트
git fetch origin

# 다른 브랜치의 상태로 강제 초기화
git reset --hard [branch]

# 변경 사항을 강제로 레포지토리에 푸시
git push master --force

.gitignore 예시

__pycache__/
.venv/
.vscode/
.idea/
*.zip
*.whl
*.pkl
*.npz
*.pth
*.txt
*.json
*.log
*.yaml
*.pdf
*.docx
*.doc
*.xlsx
*.xls
*.parquet
*.csv
*.jpg
*.jpeg
*.png
*.mp4
profile
바로 활용 가능한 정보 공유를 목적으로 합니다

0개의 댓글