Contents
🍎 Git Branch 사용법🍎 Git Branch 사용법
Git Branch를 만들기전 Git status를 체크한다.
git status

- 이 상태에서 코멘트에서
working tree clean
을 확인하고 브랜치를 생성해야된다.
- 아마 커밋을 하지 않은 상태르면
commit
이랑push
를 하고 체크해야지working tree clean
이 뜰 것이다.
Test이름의 Git Branch 생성
git branch test

test
라는 이름의 git branch를 생성하였다.
여기서
git branch
를 입력하면 어떤 브랜치가 있는지 확인 할 수 있다. git branch

- 현재
master
브랜치 안에 있는 것을 확인할 수 있다.
Brach 이동하기
git checkout test

그리고 여기서
BinaryTest01
이라는 클래스를 생성해본다. 
- 위의
BinaryTest01
는test
브랜치 안에서 생성된 클래스이다.
- 그리고 master브랜치로 이동하고 싶을 때는 꼭 커밋과 푸시를 하고 넘어가야지 저장이 된다.
master
브랜치로 이동해보겠다.git checkout master
참고로
switch
도 브랜치 이동이 가능하다.git switch master


master
브랜치로 이동을 했더니test
브랜치에서 만들었던BinaryTest01
클래스가 사라진 것을 확인 할 수 있다.
즉, 브랜치를 활용하는 이유는
코드를 완성하기 전 수많은 테스트 파일이 생성이 될 것인데,
그것 때문에
master
브랜치가 되게 난잡하게 될 가능성이 있기 때문이다.
그 master
브랜치를 깔끔하게 정리하게 위해
서 다른 브랜치들을 생성해서 사용하는 용도라고 보면 된다. Share article