Error Handling/에러핸들링

error: failed to push some refs to ! [rejected] git

sangwoo_rhie 2023. 7. 7. 17:44

Github에는 있는데, 내 로컬에는 없는 파일이 있을때 내 파일을 push하면 발생하는 오류이다. 이럴땐 pull을 먼저 하고 나서 push를 해야 한다. 

 

1. git add .

2. git commit -m 'message'

3. git pull origin main // 먼저 갖고오기.

4. gir push origin main

 

To @githup repositoty 주소
 ! [rejected]        main -> main (non-fast-forward)
error: failed to push some refs to '@githup repositoty 주소'
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.