[Git] branch 관리 기본

Woong·2021년 12월 8일
0

Git 기본

목록 보기
2/17

branch 조회

현재 local branch 조회

git branch -vv

현재 remote branch 조회

git branch -r

local, remote branch 모두 조회

git branch -a

remote branch 내역 조회

git remote show origin

remote branch 정보 업데이트

local 저장소의 모든 branch 업데이트

  • 변경사항 merge 는 발생하지 않음

Fetch updates for a named set of remotes in the repository as defined by remotes..

git remote update

모든 remote branch fetch

git fetch -all

local 저장소의 모든 branch 업데이트

  • 현재 checkout 된 branch 의 remote 변경사항만 업데이트
  • 변경사항 merge 는 발생하지 않음
git fetch

branch 생성, 반영

new local branch 생성

  • 새 local branch 생성
git branch {branch_name}
  • 새 branch로 이동
git checkout {branch_name}
  • 또는 새 local 브랜치 생성 + 이동을 한번에
git checkout -b {branch_name}
  • 새로 생성한 local branch 를 원격지 (origin)에 반영
git push origin {branch_name}

branch 삭제

local branch 삭제

git branch -d {branch_name}

remote branch 삭제

git push origin --delete {branch_name}

unreachable local branch 삭제

  • local branch 중 remote 서버에서 refs 가 더이상 존재하지 않는 branch 를 제거한다.
    • 아직 push 하지 않은 local branch 는 삭제되지 않는다.
    • --dry-run : 삭제하지 않고 삭제 대상인 branch 확인
git remote prune --dry-run {remote_server}
git remote prune {remote_server} 

0개의 댓글