Git 관련 오류 로그

걸음걸음·2023년 4월 18일
0

Error

목록 보기
1/3
post-thumbnail

failed to push some refs to '레포 주소'

To '레포 주소'
! [rejected]
dev -> dev (non-fast-forward)
error: failed to push some refs to '레포 주소'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'ait push --help' for details.

협업 프로젝트를 하는 중, git에 오류가 발생
해당 브런치에 변경사항이 있었는데 그 사실을 모르고 pull을 하지 않고 push를 해버린 탓에 발생한 오류였다.

git pull origin (해당브런치)

push를 하기 전이었다면 그냥 pull을 하는 것으로 해결되었겠지만, 이미 push까지 하고 오류가 난 상황이라 다시 에러 발생

* 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: git confia pull. rebase false # merge
hint: git config pull. rebase true # rebase
hint: git config pull.ff only # fast-forward only
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-onlv on the command line to override the configured default per
hint: invocation.
fatal: Need to specify how to reconcile divergent branches.

git reset HEAD~
커멘드로 commit한 부분 취소

그렇지만 여전히 git pull origin (브런치)를 하면 위와 같은 오류가 발생했다.
rebase, merge(default), fast-forward 를 명시적으로 정해달라고 하는 warning

git config pull.ff only

fatal: Not possible to fast-forward, aborting.

해당 명령어를 사용했더니 위와 같은 에러 메세지가 발생.
레포(원격 저장소)에 업데이트 사항이 존재하는데 git pull을 하지 않은 상태에서 commit을 했을 때 발생한다고 한다.

git pull --rebase
현재 브런치의 기준점을 변경, 다른 브렌치의 변경사항을 적용해 통합하는 명령어
해당 명령어를 사용함으로써 성공적으로 레포의 코드를 성공적으로 pull 해올 수 있었고 그 후 무사히 깃 커밋을 할 수 있었다.

깃을 협업으로 사용해보는 건 처음이라 아직 pull 하는 습관이 들어있지 않은 것이 문제. pull 을 하는 습관을 들일 것.

profile
꾸준히 나아가는 개발자입니다.

0개의 댓글