로컬과 원격이 동기화 되지 않음
Aug 10, 2024
»
Error
! [rejected] master -> master (fetch first)
에러 내용
! [rejected] master -> master (fetch first)
error: failed to push some refs to 'https://github.com/hyeran1216/hyeran1216.github.io.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. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
에러 원인
로컬 저장소와 원격 저장소가 동기화되지 않아 발생하는 문제
기존 데이터가 손실될 수 있기 때문에 push를 막은 것
해결 방법
-
동기화 후 push 진행
git pull --rebase origin master #git pull --rebase [원격저장소별칭][브랜치] git push -
강제 push
git push origin +main이 방법은 pull 하지 않은 변경사항은 삭제된다고 한다 왠만하면 쓰지 말 것