[Git] Fatal: Not possible to fast-forward, aborting / fatal: 정방향이 불가능하므로, 중지합니다.

Fatal: Not possible to fast-forward, aborting.
fatal: 정방향이 불가능하므로, 중지합니다.

잘 돌아가던 git가 push를 하니 이런 에러를 뱉어냈다. 우선 별 문제는 아니니 걱정하지 않아도 된다. 일단은 아래 명령으로 해결된다.

git pull --rebase

이후에 push하면 잘 된다.

그러나 다시 이런 에러 메시지를 만나지 않으려면 아래까지 읽어야 한다.

왜 이런 일이 벌어지는 것일까?

별다른 설정 없이 git pull을 한 뒤 아래와 같은 메시지를 본 적이 있을 것이다.

warning: Pulling without specifying how to reconcile divergent branches is
discouraged. You can squelch this message by running one of the following
commands sometime before your next pull:

  git config pull.rebase false  # merge (the default strategy)
  git config pull.rebase true   # rebase
  git config pull.ff only       # fast-forward only

You can replace "git config" with "git config --global" to set a default
preference for all repositories. You can also pass --rebase, --no-rebase,
or --ff-only on the command line to override the configured default per
invocation.

위 설명에 나오는 명령중 세 번째(git config pull.ff only)가 fast-forward만 하겠다는 것이다. 이 경우 merge가 불가능하고, merge가 필요한 경우에는 정방향으로 진행하는 게 불가능하다는 에러 메시지가 뜨면서 진행을 하지 않는 것이다.

즉, 허용되는 경우는 아래와 같은 경우다.

  • 리모트가 로컬보다 앞서 있고, merge할 것은 없다.
  • 로컬이 리모트보다 앞서 있고, merge할 것은 없다.

그래서 문제를 근본적으로 해결하려면 fast-forward only 옵션을 꺼야 한다. 아래 명령을 내려서 끈다.

git config --unset pull.ff

여담

나는 평소에 rebase보다는 merge를 선호해 git config pull.rebase false 명령을 내리곤 했는데, 이번엔 무심코 fast-forward를 선택한 모양이다. 뭔가 저장소가 꼬인 건가 싶었는데 별 게 아니었다.

카테고리 글 목록 👉

대표글

댓글 남기기