Git 기본 명령어
git 파일 초기화 및 생성
git init
저장소 복제 및 다운로드
git clone <Github Repository URL>
작업 디렉토리와 인덱스의 상태를 확인
git status
github 주소와 연결
git remote add origin 프로젝트 주소
# 리모트된 주소 확인하기
git remote
git remote -v
commit 할 파일 스테이징
git add
git add *
# 변경사항 모두 포함
git add -A
git commit
git commit -m "message"
git push
git push origin [브랜치명]
git pull(가져오기)
git pull origin 브랜치명
# 예시
git pull origin dev
# 특정 파일만 pull
git checkout 브랜치명 -- 파일명
# 예시
git checkout dev -- prisma/schema.prisma
두 브랜치 차이 비교
git diff 브랜치명 다른 브랜치명
# stage 되어 있으나 아직 commit 되지 않은 변경 비교
git diff --staged
브랜치
브랜치 생성
git branch 브랜치이름
# 생성 후 이동
git branch -b 브랜치 이름
해당 브랜치로 이동
git checkout 브랜치이름
git switch 브랜치이름
현재 브랜치 확인
git branch
모든 브랜치 확인
git brach -a
브랜치 삭제
git branch -d [브랜치 이름]
현재 브랜치에 다른 브랜치 수정사항 병합
git merge [다른 브랜치 이름]
파일 및 폴더 add
git add .
커밋
git commit -m "commit message"
# 최근 커밋 메시지 재작성
git commit --amend
git push
git push origin [브랜치명]
전체 config 리스트 확인
git config --list
git config 설정하는 방법
git config --global user.name "홍길동"
git config --global user.email "name@naver.com"
git config 삭제하기
git config --unset user.name
git config --unset user.email
# global 지정된 변수라면
git config --unset --global user.name
git config --unset --global user.email
git stash : 변경 내용 되돌리고 임시 저장
# modified, staged 변경 내용 임시 저장
git stash
git stash save
# stashed 조회
git stash list
# stash 내역 working directory로 추가
git stash pop
# stash file 제거
git stash drop