본문 바로가기

TIL/Git & Github

[TIL][Git][CLI] GIT으로 뭘할건데? - 4. merge 합치기! 삼단변신!

merge 의 형식에는 다양한 형식이 있다.

 

1. 간단한 merge : a fast-foward

지난 포스팅을 보면 새로운 브랜치 foodmarket를 만들었고 2개의 커밋을 더했다.

이 foodmarket 브랜치를 master 브랜치에 합쳐보자.

 

그러기 위해서는 합칠 master로 가서 merge foodmarket 으로명령한다

1) git switch 합칠 본체 

2) git merge 합칠 대상

git merge foodmarket
Updating e469ba4..1164c75
Fast-forward
 chinese.txt | 5 +++++
 1 file changed, 5 insertions(+)
 create mode 100644 chinese.txt

저 hash들을 보면

Updating e469ba4..1164c75

라고 써있는 것은 e469ba4 커밋에 1164c75 커밋까지 다 합쳤다.

 

2. 또 다른 브랜치와 합병  : recursive  

foodmarket에 새로운 커밋과

새로운 브랜치 drinking에 두개의 커밋을 만들고

두 개의 브랜치를 합쳤다.

Merge made by the 'recursive' strategy.
 chinese.txt   | 3 ++-
 food.txt      | 4 +++-
 othermenu.txt | 3 ++-
 3 files changed, 7 insertions(+), 3 deletions(-)

메세지를 보면 the 'recursive' strategy라고 하는 것을 보아 재귀방식이라 불리는 것 같다.

 

더 많은  자료를 위해서 링크를 참조한다.

https://www.atlassian.com/git/tutorials/using-branches/merge-strategy

 

Git merge strategy options & examples | Atlassian Git Tutorial

Git merge strategies include resolve, recursive, octopus, ours, and subtree. Learn the pros and cons, and which strategy and options are best for your team

www.atlassian.com

https://www.geeksforgeeks.org/merge-strategies-in-git/

 

Merge Strategies in Git - GeeksforGeeks

A Computer Science portal for geeks. It contains well written, well thought and well explained computer science and programming articles, quizzes and practice/competitive programming/company interview Questions.

www.geeksforgeeks.org