능히 할수있다!

[Git/GitHub] Pull 오류 'fatal: Need to specify how to reconcile divergent branches.' 본문

STUDY/Git, GitHub

[Git/GitHub] Pull 오류 'fatal: Need to specify how to reconcile divergent branches.'

능히버섯와나 2023. 6. 8.

 

🚧 오류 내용

  - git에서 pull을 진행하려는데, 아래와 같은 오류가 발생했다.

From https://github.com/xx
 * branch            main       -> FETCH_HEAD
hint: You have divergent branches and need to specify how to reconcile them.
hint: You can do so by running one of the following commands sometime before
hint: your next pull:
hint: 
hint:   git config pull.rebase false  # merge
hint:   git config pull.rebase true   # rebase
hint:   git config pull.ff only       # fast-forward only
hint: 
hint: You can replace "git config" with "git config --global" to set a default
hint: preference for all repositories. You can also pass --rebase, --no-rebase,
hint: or --ff-only on the command line to override the configured default per
hint: invocation.
fatal: Need to specify how to reconcile divergent branches.

    

 

 

 🔎 분석

git config pull.rebase false  # merge
git config pull.rebase true   # rebase
git config pull.ff only       # fast-forward only

  - 직역하면 분기를 조정하는 방법을 지정하라고 하는데, hint를 보면 pull 방식을 지정하라는 의미인 것을 알 수 있으며,

    위와 같이 merge, rebase, fast-forward only 3가지 방법을 제시하고 있다.

 

    merge: 새 branch에서 작업한 내용을 기존 main branch의 히스토리를 유지하면서 main branch에 병합하는 것

    rebase: 기본 branch base자체를 재설정하여 commit을 재적용 하는 것으로 히스토리 또한 그에 맞게 변경 됨

    fast-foward only: branch를 나눠 작업하는 동안 main branch에서 작업한 내용이 없을 경우에만 빠른 병합 가능

 

Git - Rebase 하기

Git에서 한 브랜치에서 다른 브랜치로 합치는 방법으로는 두 가지가 있다. 하나는 Merge 이고 다른 하나는 Rebase 다. 이 절에서는 Rebase가 무엇인지, 어떻게 사용하는지, 좋은 점은 뭐고, 어떤 상황에

git-scm.com

 

 

 

 🪄 문제 해결

  - 위에서 설명한 3가지의 방법(merge, rebase, fast-forward only)중 자신에게 맞는 명령어를 사용 후 pull을 진행하면 되나,

     main branch에 손을 대는 rebase 방식은 충돌 등에 유의해야 한다.

 

Comments