Git

Git 실습 :: 브랜치 생성 및 커밋 적용 후 확인

gamjadori 2024. 5. 5. 10:15
728x90

<Git 실습 :: 브랜치 생성 및 커밋 적용 후 확인>

1. add-coach 브랜치 생성

admin@DESKTOP-4M8LFU2 MINGW64 ~/Desktop/git-basic (main)
$ git branch add-coach

<확인>

  • 표시가 있는 것이 현재 사용 중인 브런치
admin@DESKTOP-4M8LFU2 MINGW64 ~/Desktop/git-basic (main)
$ git branch
  add-coach
* main

 

2. 브런치 변경

admin@DESKTOP-4M8LFU2 MINGW64 ~/Desktop/git-basic (main)
$ git switch add-coach
Switched to branch 'add-coach'

<확인>

admin@DESKTOP-4M8LFU2 MINGW64 ~/Desktop/git-basic (add-coach)
$ git branch
* add-coach
  main 

 

3. 브랜치 생성과 동시에 브랜치 이동 (git switch -c)

admin@DESKTOP-4M8LFU2 MINGW64 ~/Desktop/git-basic (add-coach)
$ git switch -c new-teams
Switched to a new branch 'new-teams'

admin@DESKTOP-4M8LFU2 MINGW64 ~/Desktop/git-basic (new-teams)
$ git switch main
Switched to branch 'main'

 

4. 브랜치 이름 변경

  • add-coach에서 add-coachs로 이름 변경
admin@DESKTOP-4M8LFU2 MINGW64 ~/Desktop/git-basic (main)
$ git branch -m add-coach add-coachs

admin@DESKTOP-4M8LFU2 MINGW64 ~/Desktop/git-basic (main)
$ git branch
  add-coachs
* main

 

5. add-coach 브랜치에서 파일 수정

  • add-coach 브랜치에서 같은 작업 후 커밋 적용하면, main 브랜치에는 적용되지 않음
admin@DESKTOP-4M8LFU2 MINGW64 ~/Desktop/git-basic (main)
$ git switch main

admin@DESKTOP-4M8LFU2 MINGW64 ~/Desktop/git-basic (main)
$ git branch
* add-coach
  main
  • add-coach에서 작업 수행

<tigers.yaml>

  • coach: Grace 내용 추가
team: Tigers

manager: Jaemin

coach: Grace
members:
- Linda
- William
- David

<panthers.yaml>

  • coach: Teddy 내용 추가
team: Panthers

manager: Sebastian

coach: Teddy
members:
- Viloet
- Stella
- Anthony
- Freddie
- Sohee

<leopards.yaml>

  • coach: Oscar 내용 추가
team: Leopards

manager: Luke

coach: Oscar
members:
- Linda
- William
- David
- Olivia
- Mark

 

6. add-coach 브랜치에서 커밋

admin@DESKTOP-4M8LFU2 MINGW64 ~/Desktop/git-basic (add-coach)
$ git commit -am "Add coach Grace to Tigers"
[add-coach 5985d95] Add coach Grace to Tigers
 1 file changed, 1 insertion(+), 1 deletion(-)

admin@DESKTOP-4M8LFU2 MINGW64 ~/Desktop/git-basic (add-coach)
$ git commit -am "Add coach Oscar to Leopards"
[add-coach cf0c264] Add coach Oscar to Leopards
 1 file changed, 1 insertion(+), 1 deletion(-)

admin@DESKTOP-4M8LFU2 MINGW64 ~/Desktop/git-basic (add-coach)
$ git commit -am "Add coach Teddy to Panthers"
[add-coach 5a3b84d] Add coach Teddy to Panthers
 1 file changed, 1 insertion(+), 1 deletion(-)

 

7. main 브랜치에서 연동 확인

admin@DESKTOP-4M8LFU2 MINGW64 ~/Desktop/git-basic (add-coach)
$ git switch main
Switched to branch 'main'
  • coach 란이 없는 걸 확인