![[Git] Fast Foward Merge (VS Code 연습)](https://image.inblog.dev?url=https%3A%2F%2Finblog.ai%2Fapi%2Fog%3Ftitle%3D%255BGit%255D%2520Fast%2520Foward%2520Merge%2520%28VS%2520Code%2520%25EC%2597%25B0%25EC%258A%25B5%29%26logoUrl%3Dhttps%253A%252F%252Finblog.ai%252Finblog_logo.png%26blogTitle%3DCoding_study&w=2048&q=75)
1. 패스트 포워드 머지 (파일 생성)


각 폴더별로 git을 따로 따로 관리해야 하니 ex01만 열어준다
메인 브랜치에서 회원가입 하고, 로그인 한 뒤,
새로운 브랜치에서 다른 기능을 만든다. (커밋 3번 함)
이걸 기존 브랜치에서 '머지'할 것이다.
머지 = 코드 합치기(병합)
내가 합치고 싶은 쪽으로 checkout해서 가져와야 함

ex01에서 git init 열린 것 확인

회원가입 파일 만들고 add + commit 로그인 파일 만들고 add + commit

Git Graph로 확인해보면 현재 브랜치가 이렇게 되어있는 확인 가능
2. Topic 브랜치 생성

git checkout -b topic
가지는 하나. 가지는 분기가 되지 않는다. (새로운 줄기가 생기는 게 아님) 커밋 로그가 2개 있고, 원래 master가 로그인을 가리키고 있었는데 새로운 브랜치 topic도 로그인을 가리키고 있게 됨. (브랜치 2개가 동일한 커밋을 가리킴)
빈 동그라미 있는 곳이 head

애가 가지!! 가지는 1개. 브랜치는 포인터만 생기는거고, 가지는 1개!
3. 아이디 중복 체크 파일 생성

가지는 하나. 커밋을 하지 않으면 절대 그래프에 나타나지 않는다! checkout으로 branch를 만들면 가지가 새로 생기는게 아니라, 브랜치 포인터만 바뀐 것이다.

- 새로운 파일이 만들어지면서 토픽이 한단계 더 위로 올라갔다.
- 가지는 1개. (최초 마스터 가지)
이런 식으로 1줄로 이어진 것! 가지는 1줄! 1개! ^^


[ master로 checkout ]


- master에서 머지를 하면 (합치려는 브랜치에서 merge하기!) topic에 있는 파일들이 합쳐질 것이다.
4. 머지하기 (topic 브랜치를 master에 합치기)
git merge topic


master에 있는 파일들과 topic에 있는 파일들이 합쳐졌다!!
Share article