로컬 저장소의 프로젝트를 git 원격 저장소에 push하려고 할 때
error: failed to push some refs to '깃허브 주소'
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 pull.. 이라고 봐선 pull이 안 된 것이 문제일 것 같은데, 이는 깃허브에서 저장소 생성할 때 Read Me를 생성했기 때문에 먼저 pull을 해야 한다는 것이다.
하지만 pull을 해도,
From https://github.com/주소
* branch main -> FETCH_HEAD
fatal: refusing to merge unrelated histories
와 같은 에러가 다시 뜨는데...
신규 프로젝트를 만들 때 마주치는 현상인데, 서로 관련 기록이 없는 두 프로젝트(로컬과 원격)의 병합을 우선 거부하고 보는 것이라 한다.
git pull origin main --allow-unrelated-histories 을 입력하면 해결된다.
그 후 다시 pull & push를 하면, 알아서 잘 Merge해 준 것을 볼 수 있다.
'Programming > Error Log' 카테고리의 다른 글
[Eclipse] 가로줄 없애기, Remove horizontal line (0) | 2024.02.05 |
---|