본문 바로가기

포스트잇

[Git] ! [reject] 에러 해결 방법

728x90
반응형

 

 ! [rejected]        main -> main (non-fast-forward)
error: failed to push some refs to 'https://github.com/~~~.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.

위와 같은 에러 메세지가 떴을 때 해결방법 (다른 pc에서 업로드할 때 유독 자주 나는 에러)

 

$ git pull origin main --rebase


From https://github.com/~~/~~.git
 * branch            main       -> FETCH_HEAD
Successfully rebased and updated refs/heads/main.

git pull origin [branch] --rebase 다음과 같이 입력합니다. (제가 쓰는 branch이름이 main이라 main으로 입력했습니다.)

 

$ git push -u origin main

Enumerating objects: 70, done.
Counting objects: 100% (70/70), done.
Delta compression using up to 8 threads
Compressing objects: 100% (68/68), done.
Writing objects: 100% (69/69), 514.79 KiB | 5.15 MiB/s, done.
Total 69 (delta 9), reused 0 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (9/9), done.
To https://github.com/~/~.git
   25b3843..5b3497f  main -> main
Branch 'main' set up to track remote branch 'main' from 'origin'.

문제 없이 push가 됐습니다.

반응형