본문 바로가기
C++ 200제/코딩 IT 정보

git did not exit cleanly (exit code 1) (failed to push some refs) 해결

by vicddory 2018. 12. 26.

git did not exit cleanly (exit code 1) (failed to push some refs) 해결


git 초기 사용 시, push 에러가 발생합니다. 당연하게도 서버에 등록된 저장소와 로컬 저장소에 차이가 있어서 발생하는 겁니다. 그래서 fetch, reset 등을 활용하여 순차적으로 이 문제를 해결해야 합니다.



에러 메시지



! [rejected] branch -> branch (non-fast-forward)

error: failed to push some refs to 'remote.git'

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 'git push --help' for details.

이 포스트에선 git did not exit cleanly (exit code 1) 해결 방법 2가지를 소개합니다.


참조 사이트 : git error: failed to push some refs to


개발 환경

  1. GitLab Enterprise Edition 11.5.1-ee
  2. TortoiseGit 2.7.0.0
  3. git version 2.19.1.windows.



해결방법 1 git did not exit cleanly (exit code 1)


■ 스테이지 초기화


git reset --mixed remote/branch




위 그림처럼 Unstaged changes after reset에 항목이 존재하면 git add . 실행해서 모두 추가해 주세요.


■ 커밋


git commit -m "message"




■ push 푸쉬


git push remote branch


failed to push some refs to 오류 해결



이런 방법으로 저는 성공했습니다.


이렇게 해도 푸쉬가 안 된다면, 아래 방법을 시도해 보세요.



해결방법 2 git did not exit cleanly (exit code 1)


 스테이지 초기화


git reset --mixed remote/branch




 커밋 commit


git commit -m "message"




만약 fetch 된 상태라면 아래 같은 오류 메시지가 발생합니다.


  • Changes not staged for commit:;
  • Untracked files


그러면 위 그림처럼 해당 파일을 스테이지에 추가합니다.


git add README.md


그리고 다시 commit 시도합니다.




 push


git push remote branch


failed to push some refs to 오류 해결




이래도 안 된다 싶으면, fetch를 실행해서 일단 서버 리포지토리와 맞춰보세요. fetch는 다른 부분만 골라서 적용 시켜주는 명령어입니다.





tortoise git을 사용하신다면 마우스 오른쪽 클릭하여 메뉴를 확인할 수 있습니다.

패치 이후 다시 1, 2번을 시도해 보시길 권합니다.


git did not exit cleanly (exit code 1) (failed to push some refs) 해결

written by vicddory

댓글