0. 문제 상황


git pull을 하려는데

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.

으로 warning이 떴다.

git pull을 하려고 하면 pull 방식을 명식하라는 뜻인데, git pull은 git fetch와 merge를 합친 명령어다. 그 중 merge 방식을 명시하라는 에러다.

1. 기존 default 방식


기존 pull의 경우, pull을 받으면 불필요한 merge commit이 생성된다. 마치 3-way merge와 같은 모양새다. (아래 그림에서의 빨간색 commit이 바로 불필요한 merge commit이다.)

Untitled

<aside> 🤖 GPT4

2. git pull --ff-only


pull 하려는 원격저장소의 브랜치와 로컬저장소의 브랜치가 fast-forward 관계일 때만 pull을 허용한다.

두 브랜치가 fast-forward 관계라는 건 둘 중 하나를 의미한다.

두 브랜치가 갈라진 commit을 기준으로 로컬저장소에만 새로운 commit이 있고, 원격저장소에는 없다. 원격저장소에만 새로운 commit이 있고, 로컬저장소에는 없다.

첫번째 경우는 pull을 받아올 필요가 없으므로 두 번째의 경우에만 pull이 가능하다는 뜻이 된다.