Git

Git push error

Michelle Hwang 2021. 3. 19. 12:47
hyejunghwang@HyeJungui-MacBookAir first_flutter % git push -u origin main
To https://github.com/Michellehwang001/SeminStudy.git
 ! [rejected]        main -> main (fetch first)
error: failed to push some refs to 'https://github.com/Michellehwang001/SeminStudy.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.

 

git push -u origin main 시 에러.....

 

Why??  검색하니 요렇게 나오네..

 

간혹 github에 올리는데 위와같이 에러가 발생하는 경우가 있는데 무조건 push한다고 해서 업로드되는것이 아니라 기존 내용을 pull가져오고 난 뒤에 push해야 합니다. 만약 강제적으로 업로드 하고 싶다면 아래와같이 하면 됩니다 git push origin +master을 입력하면 강제로 업로드가 되지만 기존에 있는 내용은 삭제됩니다.