지니의 개발로그
git 브랜치 간 히스토리가 서로 관련 없을 때 병합하기 (TIL#11일차) 본문
🚩 20240429 TIL 내일배움캠프 #11일차
🔴 문제 1
IntelliJ에서 GitHub를 연동 하던 도중 아래와 같이 경고창이 뜨면서 rejected 되었다.
Push rejected
Push to origin/main was rejected
🟠 문제 1 - 분석
Show details in console을 누르면 Console 창에 친절하게 에러내용과 힌트를 통해 해야할 것을 알려준다.
13:34:06.349: [FirstJava] git -c credential.helper= -c core.quotepath=false -c log.showSignature=false push --progress --porcelain origin refs/heads/main:main
error: failed to push some refs to 'https://github.com/User/Repository name.git'
To https://github.com/User/Repository name.git
hint: Updates were rejected because the tip of your current branch is behind
! refs/heads/main:refs/heads/main [rejected] (non-fast-forward)
hint: its remote counterpart. If you want to integrate the remote changes,
Done
hint: use 'git pull' before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
로컬 저장소의 브랜치가 원격 저장소(GitHub)에 있는 브랜치보다 업데이트가 덜 되었다고 한다.
깃허브의 최신 사항을 로컬에 반영한 후 변경사항을 푸시해야 한다.
🟡 문제 1 - 시도
Git - Pull 에서 Pull to main으로 [PULL] 해보았다.
🔴 문제 2
PULL시도시 아래 오류와 함께 PULL 실패했다.
Git Pull failed
POST git-upload-pack (315 bytes)
From https://github.com/User/Repository name* branch main -> FETCH_HEAD = [up to date] main -> origin/main refusing to merge unrelated histories
refusing to merge unrelated histories :
현재 로컬 브랜치와 깃허브 원격 브랜치 간에 서로 관련이 없는 커밋 히스토리가 있다고 한다.
🟠 문제 2 - 분석
14:11:48.364: [FirstJava] git -c credential.helper= -c core.quotepath=false -c log.showSignature=false pull --no-stat -v --progress origin main
POST git-upload-pack (315 bytes) From https://github.com/User/Repository name
* branch main -> FETCH_HEAD
= [up to date] main -> origin/main
fatal: refusing to merge unrelated histories
콘솔창의 힌트를 보자.
main 브랜치에서 최신 정보를 가져오려고 시도했고,
main 브랜치가 원격 저장소의 main 브랜치와 동일한 상태. (변경사항이 없다.)
로컬 저장소의 main 브랜치와 깃허브 저장소의 main 브랜치 사이에
서로 관련 없는 커밋 이력들이 있어서 병합을 거부한다.
🟡 문제 2 - 시도
터미널 창에서 명령을 입력하기로 했다.
※ 인텔리제이에서 터미널 여는 방법 : 대상폴더 우클릭 - Open In - Terminal
git pull origin main --allow-unrelated-histories
이 명령어를 입력하고 실행한다.
git pull : 깃에 pull해라
origin : 원격저장소 이름
main : 브랜치 이름
--allow-unrelated-histories : ★브랜치 간 히스토리가 서로 관련 없을 때 병합을 허용하는 옵션
🔴 문제 3
터미널에 강제옵션을 추가한 풀 명령을 하였으나 실패하였다.
PS C:\Users\User\IdeaProjects\FirstJava> git pull origin main --allow-unrelated-histories From https://github.com/User/Repository name
* branch main -> FETCH_HEAD
error: invalid path '2-13. ?ㅼ뒿:媛?꾨컮?꾨낫 寃뚯엫 留뚮뱾湲? 린'
Merge with strategy ort failed.
'2-13. ?ㅼ뒿:媛?꾨컮?꾨낫 寃뚯엫 留뚮뱾湲?린' 😱 해괴한 문자가 떴다..
🟠 문제 3 - 분석
invalid path ??
괴문자가 떠서 인코딩 문제인가 싶어서
깃허브에 있는 기본 파일을 보러 들어갔다.
"2-13. 실습 : 게임만들기" 파일명이 보였다.
어, 혹시 ' : ' 가 문제일까????
🟡 문제 3 - 시도
영어실력보다 눈치가 빨라졌다.
"2-13. 실습 : 게임만들기" 파일명의 콜론(:)을 언더바(_)로 수정했다.
그리고 아래 명령어를 재시도 했다.
git pull origin main --allow-unrelated-histories
🟢 배움
드디어 pull에 성공!!
PS C:\Users\User\IdeaProjects\FirstJava> git pull origin main --allow-unrelated-histories
remote: Enumerating objects: 3, done. r
emote: Counting objects: 100% (3/3), done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 2 (delta 1), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (2/2), 948 bytes | 158.00 KiB/s, done.
From https://github.com/User/Repository name
* branch main -> FETCH_HEAD
e2b4ae7..bff5ed8 main -> origin/main
hint: Waiting for your editor to close the file...
'내일배움캠프' 카테고리의 다른 글
[Java] 변수 vs 매개변수? (TIL#13일차) (0) | 2024.05.02 |
---|---|
[Java] 추상클래스 vs 인터페이스? (TIL#12일차) (0) | 2024.04.30 |
🚩 20240426 TIL 내일배움캠프 #10일차 (0) | 2024.04.26 |
🚩 20240425 TIL 내일배움캠프 #9일차 (0) | 2024.04.26 |
Java 변수의 타입(자료형) - 참조형 변수 (0) | 2024.04.24 |