local의 dev 브랜치에서 작업을 하고 원격의 dev에 push를 하였다
그리고 main 브랜치로 바꾼뒤 원격 브랜치의 dev를 pull을 받으려하니 에러가 발생했다

From https://github.com/Kimsu10/Repository-name
 * branch            dev        -> 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.

원인

  • 현재 로컬 dev 브랜치와 원격 dev 브랜치가 서로 다른 이력을 가지고 있어, Git이 어떤것을 합쳐야할지 결정을 내리지 못해 발생

  • 해결방법

병합(Merge): 두 브랜치의 이력이 서로 합쳐집니다.
리베이스(Rebase): 로컬 이력을 원격 브랜치 위로 재배치하여 깔끔한 히스토리를 유지합니다.
Fast-forward: 충돌 없이 간단한 브랜치 이동이 가능한 경우에만 동작합니다.

해결

간단하게 병합하는 방법으로 해결했다

1. main 브랜치에서 원격의 dev브랜치를 받아옴

git pull --no-rebase origin dev

2. 충돌한 부분을 수동으로 해결

3. 다시 add 하고 commit

git add .
git commit -m "커밋명"

4. push main


1. main으로 checkout

2. dev 브랜치와 rebase

git pull --rebase origin dev

충돌이 났다고 뜨며

Auto-merging public/data/projects.json
CONFLICT (content): Merge conflict in public/data/projects.json
error: could not apply d4265ac... DELETE: 진행중 프로젝트
hint: Resolve all conflicts manually, mark them as resolved with
hint: "git add/rm <conflicted_files>", then run "git rebase --continue".
hint: You can instead skip this commit: run "git rebase --skip".
hint: To abort and get back to the state before "git rebase", run "git rebase --abort".
hint: Disable this message with "git config advice.mergeConflict false"
Could not apply d4265ac... DELETE: 진행중 프로젝트

이후의 커밋들과도 계속해서 문제가 될텐데 계속 해야하기때문에

git rebase --continue

댓글남기기