728x90
에러
: Github 원격 레포지토리의 main 브랜치에 내가 로컬 브랜치에서 작업한 내용을 원격 브랜치로 push후 PR할 때 발생
(즉, 원격main > 로컬 브랜치로 clone 및 pull 해옴 > 작업 후 원격 브랜치로 push > 원격 브랜치에서 원격 main으로 PR)
원인
1. 리모트 브랜치로부터 로컬 브랜치의 작업 차이가 많은 경우, (pull을 안하고 로컬 작업을 했을 경우)
2. 로컬 브랜치의 구조가 지나치게 복잡해졌을 경우
문제해결
방법 1. 로컬에 새 프로젝트를 만들어 현재 원격에 있는 main을 pull 해와서 합치는 방법 (최후의 방법)
: 깃 워크 플로우 링크 참고 : https://radpro.tistory.com/388
* 문제점 : 기존 커밋 내역은 다 날라간다
방법 2. fetch를 이용한 방법 (필자는 실패함)
출처 : https://jinyoungchoi95.tistory.com/m/43
// 업데이트할 저장소 연결하기
$ git remote add (최신 업데이트 저장소 네임) (최신 업데이트 저장소 url)
// 동기화
$ git fetch upstream (동기화할 로컬 브랜치의 origin 브랜치)
// upstream안의 디렉토리 안에 브랜치 만들어주기
$ git rebase upstream/(동기화할 로컬 브랜치)
방법 3. 로컬 main브랜치를 작업 브랜치에 merge 후 push (필자는 실패함)
출처 : https://writerroom.tistory.com/157
//git 나의 로컬 작업 브랜치
git add .
git commit -m "message"
//
git checkout main
git pull origin main
//이미 main에 있으니 굳이 안해줘도 되긴하지만, 헷갈리니 그냥 찍어주자.
git checkout main
git checkout je-posting
//중간 중간 status 를 찍어본다.
git add .
git commit -m "message" //main 받아온 이후에 commit을 다시 해준다.
git checkout main
//이 상황에서 git push 를 해주었더니, Auto-Merging 시도 후 Conflict(content)가 발생.
//해결
git merge main
//에러메시지
//error: Merging is not possible because you have unmerged files.
//hint: Fix them up in the work tree, and then use 'git add/rm <file>'
//hint: as appropriate to mark resolution and make a commit.
//로컬에서 충돌 부분들을 정리해준다. 다시 COMMIT
git add .
git commit -m //"메시지"
git push origin //내 원격 브랜치
git checkout main //내 로컬 메인으로 와서
git pull origin main //가장 최근 메인을 다시 pull
git branch 새 브랜치 // 다음 작업을 위해 새 브랜치를 따자
git checkout 새 브랜치 //새 브랜치로 이동. 이미 origin main 이 업데이트 되어 있겠지ㅏㅁㄴ.
git pull origin main // 그래도 확인한다. 역시 up to date이다.
728x90
'Java & Spring > Error' 카테고리의 다른 글
[IntelliJ] Git clone한 프로젝트 열 때, 루트 경로 및 JDK 인식 오류 (0) | 2022.10.28 |
---|---|
[SpringBoot] not enough variable values available to expand 에러 (0) | 2022.10.28 |
[Ngrok] ERR_NGROK_108. Your account is limeited to 1 simultaneous ngrok agent session. (0) | 2022.10.18 |
[SpringBoot] JRE를 이용한 WAR파일 빌드 중 Jar파일로 빌드되는 경우 (0) | 2022.10.17 |
[에러해결] Spring JPA - cannot invoke because is null 에러 (0) | 2022.10.17 |