Post

git 명령어 모음

git 명령어 모음

✅ 1. 자주 쓰는 명령어

1.1 remote

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# 1. 로컬 저장소 설정(.git/config)에 저장된 remote repo 목록을 확인
git remote -v

# 2. 로컬 저장소 설정에 remote repo 정보를 기록
git remtoe add namseok git@github.com:namseok-kim/test-api.git

# 3. 로컬 저장소 설정에서 remote repo 상세 정보 확인
git remote show namseok

# 4. remote repo URL 변경
git remote set-url origin <URL>
git remote set-url --push origin <URL> # push 전용 URL 설정

# 5. 원격에 삭제된 브랜치를 로컬 추적 브랜치에서 정리
git remote prune origin

1.2 branch

1
2
3
4
5
6
7
8
9
# 1. 현재 로컬 브랜치가 참조하는 remote 브랜치 확인
git branch -vv

# 2. 원격 추적 브랜치 목록
git branch -r

# 2. branch 변경
git switch issue/1234
git switch -c issue/1234 # 브랜치 새로 생성(create)

1.2 fetch & pull

1
2
3
# 1. 모든 원격(--all)에서 최신 참조 가져오기
git fetch --all
git fetch --all --prune # 필요 없는 추적 브랜치 정리(--prune)
This post is licensed under CC BY 4.0 by the author.