이런 에러는 주로 로컬 브랜치가 리모트 브랜치보다 앞서 있는 경우라 발생한다.
이 문제를 해결하기 위해서는 몇 가지 단계를 해야 한다.
1. 현재 브랜치 확인 작업
Git branch
2.로컬 브랜치와 리모트 브랜치 확인
Gir bracnh -vv
3.로컬브랜치 커밋 확인
Git log
4.로컬 브랜치를 리모트 브랜치로 강제로 푸시
Git push -f origin 브랜치이름
강제푸시 중요
- 강재 푸시 하기전 팀원들과 상의
- Pull request 사용 하기
|
이게 뜬다면...
Pull 전략이 필요한 이유(설명)
Git pull = git fetch + git merge FETCH_HEAD
Git pull 수행시 git merge commit 생성됨
여기서 git pull을 하는 방식중에 세 가지 소개
- git config pull.rebase false
- git config pull.rebase true
- 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
- Rebase를 통한 해결: ->git config pull.rebase true git pull origin main
- 통합 후 히스토리 연결:-> git config origin main --allow-unrelated-histories
- 푸시 시 에러 (non-fast-forward):-> git push origin main
- --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