본문 바로가기
Git

[Git] error: failed to push some refs to '' 오류 및 해결방법

by 포뇨j 2023. 10. 24.

협업 도중, git 원격저장소에 push가 되지 않는 문제가 발생했다.

 

% git push origin main
To https://github.com/원격저장소
 ! [rejected]        main -> main (non-fast-forward)
error: failed to push some refs to 'https://github.com/원격저장소'
hint: Updates were rejected because a pushed branch tip is behind its remote
hint: counterpart. Check out this branch and integrate the remote
hint: (e.g. 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

 

hint를 보면 로컬저장소의 branch tip이 원격저장소보다 뒤에 있다는 것 같다.

 

% git status
interactive rebase in progress; onto 585ce12

 

git status 입력하자 위 같이 확인됐고, 해결방법을 찾을 있었다.

나는 충돌 해결 git rebase --continue 하지않았기 때문에 main이 한참 뒤에 있었다. git add  git rebase --continue  해야한다. 

 

 

해결방법: branch 병합 후 충돌이 발생했을 경우, 충돌이 발생한 파일을 수정한 뒤 git rebase --continue을 해야한다.

 

 

git rebase --continue 전

 

% git log --oneline

 

git rebase --continue 후

 

% git rebase --continue
% git log --oneline

 

% git push origin main
% git log --oneline