본문으로 바로가기
COMMUNITY모든 이야기

운영 서버 git push 시 non-fast-forward 에러 및 강제 푸시 위험 해결 방법

빗방울 2026.10.31 06:49 2분 읽기 조회 17 · 추천 2

운영 서버에서 핫픽스 후 로컬 변경 사항을 반영하려는데 원격 브랜치와 이력이 꼬였습니다.

코드:

git checkout main
git pull origin main
# 충돌 발생 후 수정 완료
git add .
git commit -m "fix: hotfix for production"
git push origin main

오류: [rejected] main -> main (non-fast-forward)

error: failed to push some refs to '[email protected]:repo/project.git'

hint: Updates were rejected because the remote contains work that you do

hint: not have locally. This is usually caused by another repository pushing

hint: to the same ref.

시도: git pull 실행했으나 이미 커밋이 섞여 merge commit이 계속 생성됨. -f 옵션은 운영 서버라 위험해서 못 쓰는 상황.

질문: 운영 환경에서 이력 손실 없이 깔끔하게 원격 브랜치와 싱크 맞추는 최선의 방법이 무엇입니까?

모든 이야기1455

가벼운 안부부터 깊은 생각까지, 함께 나눠요.

글쓰기
총 1455개의 이야기
댓글