git pull origin dev

canyi·2023년 11월 1일
0

github

목록 보기
13/15

에러

git을 merge하고 싶을 경우 git pull origin 브런치를 했는데

branch dev -> FETCH_HEAD 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.

이와 같은 에러가 발생했습니다.

해결법

이 메세지는 git이 두 가지 이상의 코드 베이스를 어떻게 병합할 것인지 알려주는 지시사항이 포함되어 있습니다. 다음 중 하나를 선택하면 됩니다

git config pull.rebase false: 이 명령어를 사용하면 git이 변경 사항을 병합하는 방법을 선택합니다. 이는 기본적으로 merge를 수행하게 됩니다.
git config pull.rebase true: 이 명령어는 git에게 변경 사항을 병합하는 대신 rebase를 수행하도록 지시합니다.
git config pull.ff only: 이 명령어는 git에게 가능한 경우 fast-forward 병합만 수행하도록 지시합니다.
이 중에서 가장 적합한 방법을 선택하신 후, 명령어를 입력하시면 됩니다. 그리고, "--global" 옵션을 사용하시면 모든 저장소에 대해 기본 설정을 변경할 수 있습니다.

예시: git config --global pull.rebase true

이렇게 하면, 앞으로의 모든 git pull 명령에서 'rebase'가 기본적으로 수행될 것입니다.

git config pull.rebase true

나는 git config pull.rebase true라는 기능을 사용했습니다.

매칭이 안돼는 부분을 아예 github에서 git으로 병합하는 과정에서 에러코드가 섞여서 들어옵니다.

* (no branch, rebasing dev)

git checkout dev를 했는데

  • (no branch, rebasing dev) 라는 에러가 발생

이유는 dev 브랜치를 리베이스 중이라는 것을 의미합니다.

리베이스를 완료하려면,

git rebase --continue 

명령어를 사용할 수 있습니다.
만약 리베이스 과정에서 문제가 발생했다면,

git rebase --abort 

명령어를 통해 리베이스를 취소할 수도 있습니다.

git status

충돌이 발생한 부분은 보통 <<<<<<<, =======, 그리고 >>>>>>> 이런 식의 마커로 표시됩니다.

충돌을 해결한 후에는, git add <파일명> 명령을 사용해 수정된 파일을 스테이징 영역에 추가합니다. 그 후, git rebase --continue 명령을 실행하여 리베이스를 계속 진행하면 됩니다.

그런데, 여기서 주목해야 할 점이 있습니다. .pyc 파일이 충돌 목록에 포함되어 있는데, 이 파일들은 파이썬이 자동으로 생성하는 컴파일된 바이트코드 파일입니다. 이런 파일들은 일반적으로 소스 코드 관리 시스템에 포함시키지 않습니다.

.pyc 파일들은 삭제하고, .gitignore 파일에 pycache/ 라인을 추가하여 이후에 이런 파일들이 git에 의해 추적되지 않도록 하는 것이 좋습니다. 이렇게 하려면 다음 명령들을 실행하면 됩니다

find . -name "*.pyc" -delete
echo "__pycache__/" >> .gitignore
git add .gitignore
git commit -m "Ignore .pyc files"

git rebase --abort

git rebase --abort 

를 사용해서 rebase를 먼저 빠져나옵니다.

git config pull.rebase false

결국

git config pull.rebase false

를 사용했다.

자동으로 머지를 해준다.

git rebase hint

hint: Resolve all conflicts manually, mark them as resolved with
hint: "git add/rm <conflicted_files>", then run "git rebase --continue".
hint: You can instead skip this commit: run "git rebase --skip".
hint: To abort and get back to the state before "git rebase", run "git rebase --abort".
profile
백엔드 개발 정리

0개의 댓글