git checkout은 가지 사이를 이동하는 명령입니다. 새로 생성한 newfile 가지로 이동하려면 다음과 같이 명령합니다.

    administrator@vmgate:~/gittest$ git checkout newfile
    Switched to branch 'newfile'

    git branch -v 명령으로 가지치기 상태를 확인할 수 있습니다. 이름 앞에 *이 붙은 가지가 현재 작업 중인 가지이며, 가지마다 커밋 정보가 표시됩니다. master에서 분리된 newfile 가지가 보입니다.

    administrator@vmgate:~/gittest$ git branch -v
      master 5aba677 Edit failure.txt
    *  newfile 5aba677 Edit failure.txt

    newfile 가지에서 echo 명령으로 새로운 파일을 생성하고 준비 영역에 추가해서 작업을 커밋합니다.

    administrator@vmgate:~/gittest$ echo 'Why have dreams that cannot be?' > 2019AD.txt 
    administrator@vmgate:~/gittest$ git add 2019AD.txt 
    administrator@vmgate:~/gittest$ git commit -m 'Create 2019AD.txt' 
    [newfile fa7301f] Create 2019AD.txt
    ...

    새로 추가한 newfile 가지의 가장 최근 커밋은 fa7301f입니다. master 가지는 아직도 5aba677 커밋에 머물고 있습니다.

    ▲ 그림 13-6 newfile 가지 추가

    신간 소식 구독하기
    뉴스레터에 가입하시고 이메일로 신간 소식을 받아 보세요.