티스토리 뷰

반응형

이 글은, 동료와 이야기중, 나는 다른 커밋이지만 동일한 변경에 대해서도 컨플릭트가 나기에, 체리 픽을 하는게 낫다고 말했다. 그런데 실제로 그렇지 않았고, 동일한 변경에 대해 안전하게 머지가 되었다. 나는 나의 고집과 미신을 타파를 위해 좀 더 살펴보기로 했다.

실제로 내가 git을 마주한 것은 꽤 옜날 부터였고, 현재는 git version 2.39.0. 여기서는 기본적으로 ort전략이 사용된다. https://git-scm.com/docs/merge-strategies/2.34.0  

다음으로는 2.25.0 버전을 설치하여 비교하고 싶었으나, 부득이 mac에선 설치방법이 나에겐 까다로와 하지 못했다.다만, '-s' 옵션으로 스트래티지(전략)을 선택할 수 있어 수행했고, conflict가 나지 않았다. 내가 가진 미신은 이전 블로그에 서술되어있는 커밋 series에 대해서임으로 이만 글을 마쳐도 된다.(?) 당연히 ort, recursive 둘 다  3-way merge 알고리즘이라, base 브랜치 대비 브랜치 A, B와의 다른점을 찾지 못하기 때문이라고 생각한다. 그런데 둘 다 3-way merge인데 어떤 부분이 다를까? 

ORT, NEW STRATEGY FOR MERGE 

https://github.blog/2021-08-16-highlights-from-git-2-33/#merge-ort-a-new-merge-strategy 

 

Highlights from Git 2.33 | The GitHub Blog

The open source Git project just released Git 2.33, with features and bug fixes from over 74 contributors. Here's a look at some of the most interesting features and changes.

github.blog

글에 상세한 정리 내용이있다. GIT MERGE 전략의 변경은 `git merge`, `git cherry-pick(when resolving conflict)`, `git rebase`에 영향이 있다. 기본적으로 Recursive가 ORT 보다 500배 ~ 9000배 가량 느린 케이스가 있다고 하기 때문.

좀 더 상세한 내용을 알아보기 위해 OPEN AI 에게 물어봤다.

> what is big difference between git merge ort strategy and recursive strategy?
 

> In Git, merging is the process of combining changes from different branches. When merging two branches, Git offers different strategies to determine how it should combine the changes. Two of these strategies are "ort" and "recursive".

The "ort" merge strategy (which stands for "Ostensibly Recursive Twoway") is the default strategy used by Git. This strategy performs a simple three-way merge, which combines changes from the two branches and their common ancestor. If there are conflicts between the changes, Git will prompt the user to resolve them.

The "recursive" merge strategy, on the other hand, is more powerful and can handle more complex merges. It works by recursively merging branches, which means it merges the branches one by one in a specific order, using the "ort" merge strategy. This allows Git to handle cases where multiple branches have diverged from a common ancestor in different ways.

The main difference between the two strategies is their ability to handle complex merges. The "recursive" strategy is more powerful and can handle more complex merges, while the "ort" strategy is simpler and faster but may not always be able to handle complex merges.

2

> how recursive strategy is more powerful than ort strategy in git?

> The recursive merge strategy in Git is more powerful than the ort strategy in several ways:

  1. Handling complex merges: The recursive strategy is designed to handle complex merges that the ort strategy may not be able to handle. For example, if there are multiple branches that have diverged from a common ancestor in different ways, the recursive strategy can merge them in a specific order to produce a more accurate and complete merge result.
  2. Improved conflict resolution: The recursive strategy provides improved conflict resolution capabilities compared to the ort strategy. It uses a more advanced algorithm to detect and resolve conflicts, which can result in fewer conflicts that need manual resolution.
  3. Submodule merging: The recursive strategy can handle merging of Git submodules, which are separate Git repositories that are included within a parent repository. The ort strategy does not support submodule merging.
  4. Custom merge drivers: The recursive strategy allows the use of custom merge drivers, which are scripts that can be used to handle specific types of file merges. This allows for more flexibility and control over the merging process.

In summary, the recursive merge strategy in Git is more powerful and flexible than the ort strategy, and is designed to handle complex merging scenarios with greater accuracy and efficiency.

 

RECURSIVE 전략이 더 느린 이유는, 복잡한 알고리즘을 써서 때문이라고 한다.

끝. (기술문서 아니고 찌라시같네요 ^^)

반응형