1월 04, 2016

git branch 조작법

Local branch

  • local branch 이름 수정
  • git branch -m old_branch new_branch

  • remote branch를 local branch로 가져온 후 track
  • git checkout -b new_local_branch remote_branch_path

  • 모든 local branch들을 한번에 remote repository에 업로드
  • 주의! remote repository가 지저분해질 수 있음
    git push --all  git push --tags
    git push 로는 branch만 올라갈 뿐 tag는 올라가지 않음. 따라서 tag는 따로 올려줘야 함.

  • git checkout -t remote_branch_path
  • remote_branch_path를 tracking 하는 local branch를 만들고 checkout. 이 방법으로 새 local branch를 만들 시 branch의 이름은 remote branch의 이름과 동일하게 만들어짐.

Remote branch

  • remote branch 삭제
  • git push origin :old_branch or git push origin --delete romote_branch // remote branch 삭제 git fetch --all --prune // 각 local machine에서 실행. to get rid of obsolete tracking branch 제거 remote branch를 삭제해도 다른 local machine들에서는 여전히 삭제된 remote branch를 tracking 하고 있는 상태. obsolete tracking을 막기 위해 다른 local machine에서 실행 git remote rm remote_branch 랑 차이점..? 이건 remote branch가 삭제됐다고 자동으로 알려주는건가?

댓글 없음:

댓글 쓰기