git pull 오류 해결 목록

동화·2022년 12월 24일
0

코딩메모

목록 보기
2/8

1.

Need to specify how to reconcile divergent branches.

$ git pull
hint: You have divergent branches and need to specify how to reconcile them.
hint: You can do so by running one of the following commands sometime before
hint: your next pull:
hint:
hint:   git config pull.rebase false  # merge
hint:   git config pull.rebase true   # rebase
hint:   git config pull.ff only       # fast-forward only
hint:
hint: You can replace "git config" with "git config --global" to set a default
hint: preference for all repositories. You can also pass --rebase, --no-rebase,
hint: or --ff-only on the command line to override the configured default per
hint: invocation.
fatal: Need to specify how to reconcile divergent branches.

해결 방법 🧐

아래 3가지 방법 중 하나로 pull 한다

git pull --no-rebase ##
git pull --rebase
git pull --ff-only



2.

❌ Pulling without specifying how to reconcile divergent branches is discouraged

찾아보니 git 2.27 부터 새로 추가된 기능이라 한다.
repository를 pull 땡길때는 rebase, merge, fast-forward 방법이 있는데 -> 이제 이를 명시적으로 정해달라고 warning을 띄워주는듯하다.

해결 방법 🧐

해당 레포지토리에만 적용 시

git config pull.ff only

앞으로의 모든 레포지토리에 대해 적용 시

git config --global pull.ff only



3.

Fatal: 정방향이 불가능하므로, 중지합니다.

해결 방법 ⁉️

git pull --rebase 

++ global의 fast-forward only 옵션 끄기

git config --unset pull.ff
git config --unset --global pull.ff

둘 중에 하나를 입력하면 에러가 안 나게 된다.



4.

error: 다음 파일의 로컬 변경 사항을 체크아웃 때문에 덮어 쓰게 됩니다.
브랜치를 전환하기 전에 변경 사항을 커밋하거나 스태시하십시오. 중지함

해결 방안 🔎

git stash
git checkout main
git stash pop

셋 중에 하나 사용
나는 stash를 이용했다.
저 파일들을 모두 커밋해야하나... 했는데 스태시로 간단히 해결되는 부분





git stash ❓

stash 저장소는 임시저장소입니다.
프로젝트에서 작업을 하고 있었습니다.
그런데 다른 요청이 들어와서 다른 일을 먼저 진행하게 되었습니다.
해당 요청을 처리하기 위해서는 branch의 전환이 필요합니다.
하지만 branch를 전환하기 위해서는 Index Storage의 데이터를 비워야합니다.
그러기 위해 commit을 이용할 수 있습니다.
하지만 commit은 커밋 로그가 남으며 원하는 목적과 동떨어집니다.
이럴때 임시 저장소로 사용할 수 있는것이 바로 stash 명령어이며,
이 명령어는 stash Area를 사용합니다.

(참고 : https://sabarada.tistory.com/156)

즉, 현재까지 작업한 내용을 커밋하지 않고 별도의 임시 저장소에 저장하는 명령으로 그러니까 작업중인 파일들을 숨겨둘 수 있는 것이다.

git stash : 작업 내용을 스택에 넣어둠
git checkout main : 원래 하려던 작업 (checkout or pull)
git stash pop : 스택에 넣어둔 변경 사항을 적용하고, 스택에서 제거

0개의 댓글