발생 Error
Git Bash에서 다음 명령어를 입력할 경우,
$ git push -u origin main
To https://github.com/HJ0216/TIL.git
! [rejected] main -> main (fetch first)
error: failed to push some refs to 'https://github.com/HJ0216/TIL.git'
⭐ ! [rejected] main -> main (fetch first)
⭐ error: failed to push some refs to 'https://github.com/HJ0216/TIL.git'
Error 발생
Error 원인
원격 저장소의 main branch에 저장되어있는 내용과 로컬 저장소의 내용이 일치하지 않아 발생
해결 방법
원격 저장소 내용을 로컬 저장소에 먼저 pull 시킴
$ git pull origin main
remote: Enumerating objects: 247, done.
remote: Counting objects: 100% (247/247), done.
remote: Compressing objects: 100% (187/187), done.
remote: Total 247 (delta 73), reused 157 (delta 38), pack-reused 0
Receiving objects: 100% (247/247), 59.49 KiB | 378.00 KiB/s, done.
Resolving deltas: 100% (73/73), done.
From https://github.com/HJ0216/TIL
* branch main -> FETCH_HEAD
* [new branch] main -> origin/main
fatal: refusing to merge unrelated histories
⚠️ 추가 문제: fatal: refusing to merge unrelated histories Error 발생
(참조: [해결 방법] fatal: refusing to merge unrelated histories)
참고 자료
📑[GitHub] Repository에 'main' branch로 push 하기
'DevOps > Git' 카테고리의 다른 글
[해결 방법] fatal: refusing to merge unrelated histories (0) | 2023.01.22 |
---|---|
Git 설치 및 초기 설정 (0) | 2023.01.22 |
[해결 방법] fatal: The current branch main has no upstream branch (0) | 2023.01.19 |
[해결 방법] fetal: bad source (0) | 2023.01.19 |
[해결 방법] this operation must be run in a work tree (0) | 2023.01.16 |