Git rebase 충돌 해결 과정

lisoh·2022년 4월 27일
1

마주친 에러들

목록 보기
1/1
post-thumbnail

ㅠ 얼레벌레 해결하긴 했는데 이 방법의 정확한 작동 원리는 아직 모르겠다.

문제 상황

터미널에서 만든 로컬저장소와 Github에서 만든 원격저장소를 연결하려고 하다 제대로 commit이 안되는 현상이 발생했다..

혈투 과정

  1. vscode를 열고 터미널을 연 뒤 npx create-next-app을 입력했다.

  2. 폴더 이름을 만들래서 nextjs-practice로 만든 후에 만든 폴더 안에 들어갔다.

  3. nextjs-practice 폴더를 git init으로 깃 초기화를 시켜주고

  4. 미리 만들어둔 깃허브 원격 저장소주소를 git remote add origin 저장소 주소~ 입력해서 폴더 깃저장소와 연결?해주었다.

  5. 원격 저장소의 main 브랜치에 있는 것들을 pull해주려고 git pull을 했더니 뭔가 받아졌다.

  6. create-next-app을 실행하고 만들어진 파일들을 push해주려고 했더니 안되기 시작했다!!

  7. 다시한번 git pull을 입력하니 뭔가 원격 저장소와 연결이 잘 안되서 나오는 듯한 에러메시지가 나왔다.


fatal: '../..' does not appear to be a git repository
fatal: 리모트 저장소에서 읽을 수 없습니다
<br>
올바른 접근 권한이 있는지, 그리고 저장소가 있는지
확인하십시오.
현재 브랜치에 추적 정보가 없습니다.
어떤 브랜치를 대상으로 병합할지 지정하십시오.
자세한 정보는 git-pull(1) 페이지를 참고하십시오.
<br>
    git pull <리모트> <브랜치>
<br>
이 브랜치에 대한 추적 정보를 설정하려면 다음과 같이 할 수 있습니다:
<br>
    git branch --set-upstream-to=origin/<브랜치> main

  1. 이런 메시지가 나와서 git remote로 원격 저장소를 확인해줬더니
    일단 origin이라는 애가 나왔다..

  2. 정확하게 연결된 원격 저장소 주소를 알고 싶어 다시 알아보았다.


origin  https://github.com/lisohh/Nextjs-Practice.git (fetch)
origin  https://github.com/lisohh/Nextjs-Practice.git (push)

  1. 연결은 잘 되었는데? 그럼 main 브랜치를 콕 집어서 pull을 해보자.
❯ git pull Nextjs-Practice main
fatal: 'Nextjs-Practice' does not appear to be a git repository
fatal: 리모트 저장소에서 읽을 수 없습니다

올바른 접근 권한이 있는지, 그리고 저장소가 있는지
확인하십시오.

  1. pull 뒤에 저장소 이름을 그대로 쓰는게 아닌가보다..
  2. 로컬의 main 브랜치와 원격의 main브랜치를 연결하는 명령을 입력했다.
❯ git branch --set-upstream-to=origin/main  main   
'main' 브랜치가 리모트의 'main' 브랜치를 ('origin'에서) 따라가도록 설정되었습니다.

  1. 뭔가 연결이 된거 같으니.. 이제 rebase를 시도해보았다.
git config pull.rebase true   # rebase

  1. 여기서 갑자기 rebase모드로 들어가서는 commit을 누르니까
    Terminal is dumb, but EDITOR unset 요딴 메시지가 모달창에 뜬다..

  2. rebase 충돌 이라고 검색하다가 우연히 발견한 블로그에서 한대로 따라했더니 중간도 안가서 갑자기 해결이 되었다. ;;;
    rebase 충돌 해결방법

내가 따라한 부분은 블로그 글 중
commit message 수정하지 않고 그대로 push 할 예정~뒤부터 인데

  • pick 커밋 메시지 를 터미널에 입력하고 (커밋 메시지는 입력창에 뜬 그대로 복붙)
  • esc를 눌러 insert 모드를 나간 후에
  • :wq명령어로 vim 을 나온다.


    이렇게만 했는데 그 다음 순서를 하기도 전에 rebase가 잘 되었다는 메시지가 터미널에 나와서, main 브랜치로 돌아와 push해주니 오류없이 잘 작동했다 ㅠㅠ

터미널 명령어 기록 전문

(rebase과정은 자동으로 사라져서 가져오지 못했다.)

 ~/repository/nextjs-practice  main ▓▒░                                       ░▒▓ 15:37:11  
❯ git remote add origin  https://github.com/lisohh/Nextjs-Practice.git

 ~/repository/nextjs-practice   main ▓▒░                                       ░▒▓ 15:38:02  
❯ git pull
remote: Enumerating objects: 3, done.
remote: Counting objects: 100% (3/3), done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
오브젝트 묶음 푸는 중: 100% (3/3), 676 bytes | 338.00 KiB/s, 완료.
https://github.com/lisohh/Nextjs-Practice URL에서
 * [새로운 브랜치]   main       -> origin/main
현재 브랜치에 추적 정보가 없습니다.
어떤 브랜치를 대상으로 병합할지 지정하십시오.
자세한 정보는 git-pull(1) 페이지를 참고하십시오.

    git pull <리모트> <브랜치>

이 브랜치에 대한 추적 정보를 설정하려면 다음과 같이 할 수 있습니다:

    git branch --set-upstream-to=origin/<브랜치> main


 ~/repository/nextjs-practice  main ▓▒░                                       ░▒▓ 15:38:07 
❯ git pull ...
fatal: '../..' does not appear to be a git repository
fatal: 리모트 저장소에서 읽을 수 없습니다

올바른 접근 권한이 있는지, 그리고 저장소가 있는지
확인하십시오.

 ~/repository/nextjs-practice  main ▓▒░                                       ░▒▓ 15:39:22 
❯ git pull
현재 브랜치에 추적 정보가 없습니다.
어떤 브랜치를 대상으로 병합할지 지정하십시오.
자세한 정보는 git-pull(1) 페이지를 참고하십시오.

    git pull <리모트> <브랜치>

이 브랜치에 대한 추적 정보를 설정하려면 다음과 같이 할 수 있습니다:

    git branch --set-upstream-to=origin/<브랜치> main


 ~/repository/nextjs-practice  main ▓▒░                                       ░▒▓ 15:39:43  
❯ git remote
origin

 ~/repository/nextjs-practice  main ▓▒░                                       ░▒▓ 15:40:18  
❯ git remote -b
error: unknown switch `b'
사용법: git remote [-v | --verbose]
  또는: git remote add [-t <브랜치>] [-m <master>] [-f] [--tags | --no-tags] [--mirror=<fetch|push>] <이름> <url>
  또는: git remote rename <옛이름> <새이름>
  또는: git remote remove <이름>
  또는: git remote set-head <이름> (-a | --auto | -d | --delete | <브랜치>)
  또는: git remote [-v | --verbose] show [-n] <이름>
  또는: git remote prune [-n | --dry-run] <이름>
  또는: git remote [-v | --verbose] update [-p | --prune] [(<그룹> | <리모트>)...]
  또는: git remote set-branches [--add] <이름> <브랜치>...
  또는: git remote get-url [--push] [--all] <이름>
  또는: git remote set-url [--push] <이름> <새url> [<옛url>]
  또는: git remote set-url --add <이름> <새url>
  또는: git remote set-url --delete <이름> <url>

    -v, --verbose         자세히 표시합니다 (하위 명령 앞에 와야 합니다)


 ~/repository/nextjs-practice  main ▓▒░                                ░▒▓ HUP ✘  15:40:24  
❯ git remote -v
origin  https://github.com/lisohh/Nextjs-Practice.git (fetch)
origin  https://github.com/lisohh/Nextjs-Practice.git (push)

 ~/repository/nextjs-practice  main ▓▒░                                       ░▒▓ 15:40:29 
❯ git pull Nextjs-Practice main
fatal: 'Nextjs-Practice' does not appear to be a git repository
fatal: 리모트 저장소에서 읽을 수 없습니다

올바른 접근 권한이 있는지, 그리고 저장소가 있는지
확인하십시오.

 ~/repository/nextjs-practice  main ▓▒░                                       ░▒▓ 15:41:46 
❯ git branch --set-upstream-to=origin/<branch> main
zsh: no such file or directory: branch

 ~/repository/nextjs-practice  main ▓▒░                                       ░▒▓ 15:42:21 
❯ git branch --set-upstream-to=origin/main  main   
'main' 브랜치가 리모트의 'main' 브랜치를 ('origin'에서) 따라가도록 설정되었습니다.

 ~/repository/nextjs-practice  main ⇣1⇡1 ▓▒░                                  ░▒▓ 15:42:38 
❯ git config pull.rebase true   # rebase

 ~/repository/nextjs-practice  main ⇣1⇡1 ▓▒░                                  ░▒▓ 15:42:59 
❯ git rebase --continue
[HEAD 분리됨 bf4efb2] Initial commit from Create Next App
 13 files changed, 1935 insertions(+)
 create mode 100644 .eslintrc.json
 create mode 100644 .gitignore
 create mode 100644 next.config.js
 create mode 100644 package.json
 create mode 100644 pages/_app.js
 create mode 100644 pages/api/hello.js
 create mode 100644 pages/index.js
 create mode 100644 public/favicon.ico
 create mode 100644 public/vercel.svg
 create mode 100644 styles/Home.module.css
 create mode 100644 styles/globals.css
 create mode 100644 yarn.lock
Successfully rebased and updated refs/heads/main.
profile
프론트엔드 개발자를 꿈꾸는 개발초보 호랑이

0개의 댓글