카테고리 없음

git push 에러 현재 브런치의 끝이 리모트 브랜치보다 뒤에 있으므로 업데이트 거부되었습니다.

김가마 2022. 11. 23. 20:45

 

이런 에러는 주로 로컬 브랜치가 리모트 브랜치보다 앞서 있는 경우라 발생한다.

이 문제를 해결하기 위해서는 몇 가지 단계를 해야 한다.

 

1. 현재 브랜치 확인 작업

Git branch 

2.로컬 브랜치와 리모트 브랜치 확인

Gir bracnh -vv

3.로컬브랜치 커밋 확인

Git log

4.로컬 브랜치를 리모트 브랜치로 강제로 푸시 

Git push -f origin 브랜치이름

 

강제푸시 중요 

  1. 강재 푸시 하기전 팀원들과 상의
  2. Pull request 사용 하기

|

 

이게 뜬다면...

 

 

Pull 전략이 필요한 이유(설명)

Git pull = git fetch + git merge FETCH_HEAD

Git pull 수행시 git merge commit 생성됨

 

여기서 git pull을 하는 방식중에 세 가지 소개

  1. git config pull.rebase false
  2. git config pull.rebase true
  3. git config pull.ff only

 

두번째 [git config pull.rebase true] 방법을 선택하고,  pull 명령어에 옵션을 줘서 가져오면 간단하게 해결된다.

에러 처리 및 추가 명령어:

[git pull origin main  fatal: refusing to merge unrelated histories

에러: fatal: refusing to merge unrelated histories

<rebase>

git config pull.rebase

git config pull.rebase true

 

 

  1. Rebase를 통한 해결: ->git config pull.rebase true git pull origin main
  2. 통합 후 히스토리 연결:-> git config origin main --allow-unrelated-histories
  3. 푸시 시 에러 (non-fast-forward):-> git push origin main
  4. --allow-unrelated-histories 사용하여 강제로 pull: -> git pull origin master --allow-unrelated-histories
config --list

config --global -user.name
config --global -user.email


통합 하기 

git config pull.rebase

git config pull.rebase true

히스토리 연결
git config origin main --allow -unrelated-histories

* main=> fetch_head

git status
git log
git push origin main
 푸시 올리기

git push 에러 (non-fast-forward)

git pull origin master __allow_unrelated_histories