Git

git pull 오류 / git pull 전략 / fetch vs merge

민돌v 2022. 5. 24. 00:38
728x90

맥북 git pull 에러

 ! [rejected]        master -> master (fetch first)
error: 레퍼런스를 'https://bitbucket.org/thalsal/test.git'에 푸시하는데 실패했습니다
힌트: 리모트에 로컬에 없는 사항이 들어 있으므로 업데이트가
힌트: 거부되었습니다. 이 상황은 보통 또 다른 저장소에서 같은
힌트: 저장소로 푸시할 때 발생합니다.  푸시하기 전에
힌트: ('git pull ...' 등 명령으로) 리모트 변경 사항을 먼저
힌트: 포함해야 합니다.
힌트: 자세한 정보는 'git push --help'의 "Note about fast-forwards' 부분을
힌트: 참고하십시오.
hmin@hmins-MacBook-Pro test % git pull origin master
warning: 공통 커밋 없음
remote: Enumerating objects: 4, done.
remote: Counting objects: 100% (4/4), done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 4 (delta 0), reused 0 (delta 0), pack-reused 0
오브젝트 묶음 푸는 중: 100% (4/4), 1.71 KiB | 437.00 KiB/s, 완료.
https://bitbucket.org/thalsal/test URL에서
 * branch            master     -> FETCH_HEAD
힌트: You have divergent branches and need to specify how to reconcile them.
힌트: You can do so by running one of the following commands sometime before
힌트: your next pull:
힌트:
힌트:   git config pull.rebase false  # merge
힌트:   git config pull.rebase true   # rebase
힌트:   git config pull.ff only       # fast-forward only
힌트:
힌트: You can replace "git config" with "git config --global" to set a default
힌트: preference for all repositories. You can also pass --rebase, --no-rebase,
힌트: or --ff-only on the command line to override the configured default per
힌트: invocation.
fatal: Need to specify how to reconcile divergent branches.

 

 

git pull error

 


에러 이유

 

git pull 정책 명시해주지 않아서 나오는 오류라고 한다

git 2.27부터 새로 추가된 기능이고, 

레포지토리에서 pull을 받을 때, pull 전략을 명시해주어야한다 (rebase, merge, fast-forward : ff)

 

 

pull 전략이 필요한 이유

- git pull 은 git merge FETCH_HEAD와 같이 동작함

git pull = git fetch + git merge FETCH_HEAD

-> 따라서 기본 모드는, git pull 수행 시 git merge commit 생성됨

 

 

-> fetch와 merge 의 차이점

 

 

[GIT] Git pull 전략 (default, --ff -only, --rebase)

git pull 을 별도 옵션 없이 하게되면 다음과 같은 warning 이 발생하는 것을 볼 수 있습니다. warning: Pulling without specifying how to reconcile divergent branches is discouraged. You can squelch this..

sanghye.tistory.com

 

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

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

 

 

 

 

 

참고

1. https://synapsis9.tistory.com/entry/git-pull-%EA%B2%BD%EA%B3%A0%EC%97%86%EC%95%A0%EA%B8%B0-Pulling-without-specifying-how-to-reconcile-divergent-branches-is-discouraged

 

2. https://coding-sojin2.tistory.com/20

반응형