(GIT)Branch

지며리·2023년 1월 11일
0
post-thumbnail

Branch 조회

git branch

  • 로컬 branch를 조회

git branch -r

  • remote branch를 조회

git branch -a

  • local과 remote의 branch를 모두 조회

Branch 생성, 이동(local)

git branch branch_name

  • 로컬에 branch_name 이라는 이름의 branch를 현 위치에서 생성

git checkout branch_name

  • 로컬에 branch_name이라는 이름의 branch로 이동

git checkout -b branch_name

  • 로컬에 branch_name이라는 이름의 branch가 없으면 새로 생성하고 이동까지 실행
  • 로컬에 branch_name이라는 이름의 branch가 있으면 에러

Branch 생성(remote)

git push origin branch_name

  • remote repository에 local에서 만든 branch를 생성

Branch 삭제(local)

git branch -d branch_name

  • 삭제하려는 branch에 위치하지 않아야 삭제가 가능
  • git checkout other_branch_name(다른 branch로 이동) 후 삭제하기

Branch 삭제(remote)

git push origin --delete branch_name

  • --delete 추가
profile
호지자불여락지자

0개의 댓글