hg branch 명령어 



// 아무 옵션없으면 현재 브랜치 이름 출력
C:\rep> hg branch
default

// 브랜치 만들기. (하지만 다음 커밋할 때까지 이 브랜치는 실제로는 존재하지 않는 상태)
C:\rep> hg branch BRANCH-1
marked working directory as bracnch BRANCH-1

C:\rep> hg branch
BRANCH-1

// -f 혹은 --force 옵션을 주지 않았을 경우, 이미 존재하는 브랜치를 한 번 더 만들려고 하면 아무 일도 일어나지 않음

// -C 혹은 --clean 옵션을 주면 부모 브랜치로 돌아감
C:\rep> hg branch BRANCH-2
marked working directory as branch BRANCH-2

C:\rep> hg branch
BRANCH-2

C:\rep> hg branch --clean
reset working directory to branch BRANCH-1

C:\rep> hg branch
BRANCH-1


/*********************************
현재 저장소의 브랜치 리스트 관련 명령어: branches
*********************************/
// 현재 저장소 브랜치 리스트 출력 (closed 된 리스트는 출력 안됨)
C:\rep> hg branches
BRANCH-1
BRANCH-3 (inactive)

// -a 혹은 --active 옵션을 이용하면 독자적인 head를 가진 merge되지 않은 브랜치 리스트 출력
C:\rep> hg branches -a
BRANCH-1

// -c 혹은 --closed 옵션을 이용하면 closed된 브랜치도 출력
C:\rep> hg branches -c
BRANCH-1
BRANCH-2 (closed)
BRANCH-3 (inactive)



/*********************************
브랜치 간 이동은 update 명령어로 수행
*********************************/
C:\rep> hg up BRANCH-2
2 files updated, 0 files merged, 0 files removed, 0 files unresolved



/********************************* 
원격저장소의 default 브랜치와 merge
*********************************/
// 1. incoming 내용이 있는지 확인
C:\rep> hg in -b default

// 2. merge할 내용이 있다면 pull
C:\rep> hg pull -b default

// 3. merge
C:\rep> hg merge default

// conflict가 날 경우 수동으로 merge 진행

// 4. merge 내용 반영
C:\rep> hg commit -m "Merge with default"

/********************************* 
원격저장소에 push
*********************************/
// push할 브랜치를 지정만 하면 됨
C:\rep> hg push -b BRANCH-1
// 혹은 .(현재브랜치) 지정
C:\rep> hg push -b .

// 최초 push일 경우 원격저장소에 해당 브랜치가 없으므로 --new-branch 옵션이 필요함.
C:\rep> hg push -b . --new-branch

/********************************* 
브랜치 닫기 (close)
  - 그냥 개념상의 close 이고, 브랜치 자체가 히스토리에서 사라지거나 하지 않고 언제든지 reopen 가능.
  - 가벼운 브랜칭을 하려면 bookmark 를 이용해야 함.
*********************************/
C:\rep> hg commit --close-branch -m "close branch"








Posted by bloodguy
,