728x90
🎇 Git push error solution
새 프로젝트를 진행하려고 로컬에 repository를 생성한 뒤 github에 push 하려고 하자 아래와 같은 오류가 발생했다.
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.
찾아보니 github repository를 생성할 때 readme.md를 생성했기 때문에 발생하는 오류라고 한다.
이를 해결하기 위해선 pull을 해주면 된다고 하길래 pull을 해주었으나 또 다른 오류가 발생했다.
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에서 처리 되지 않도록 에러를 띄우는 것이라고 한다.
근본적인 원인을 찾아 해결할 수도 있지만 임시방편으로 “+”를 이용하여 해결이 가능하다고 한다.
아래와 같이 입력하면 에러 상관없이 강제로 push 를 진행하게 된다.
🎇 해결 방법
$ git push -u origin +master
728x90
'개발&etc > Git' 카테고리의 다른 글
[Git] gitignore 작동/적용이 안될 때. (0) | 2023.03.25 |
---|---|
[Git] github에 100MB이상 파일 PUSH하기 (0) | 2023.02.28 |
[Git] ![remote rejected] main -> main (pre-receive hook declined) 에러 (0) | 2023.02.28 |
[Git] Please enter a commit message to explain why this merge is necessary, especially if it merges an updated upstream into a topic branch 에러메세지 해결 (0) | 2023.02.27 |
[Git] Git 캐시 삭제하기 (0) | 2023.02.22 |