[ Git ] Error log - Git 터미널 : fetch 하고 push, rsh 터미널 세팅

2023. 5. 11. 01:51devOps

깃허브 브랜치를 master 기본으로 세팅하려고 git switch master 를 하려고 하는데

이런 메세지가 뜸..

error: Your local changes to the following files would be overwritten by checkout:
    iOSudemy/Calculator-Layout-iOS13_BySeohyun/Calculator Layout iOS13.xcodeproj/project.pbxproj
    iOSudemy/Calculator-Layout-iOS13_BySeohyun/Calculator Layout iOS13/Main.storyboard
Please commit your changes or stash them before you switch branches.
Aborting
Please commit your changes or stash them before you switch branches.  
Aborting

=> 브랜치를 변경하기 전에 변경된 내용을 commit 하거나 그것들을 stash (안전한 곳에 넣어둬라)

  • stash : 해당 브랜치에 커밋할 준비가 되지 않은 변경 사항을 작업한 상태에서 다른 브랜치로 전환해야할 때 사용

Try Catch 1.

  1. git add . -> git commit -m "커밋메시지"
  2. git push origin [branch명]
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that a host key has just been changed.
The fingerprint for the RSA key sent by the remote host is
SHA256:SHA256키 블라블라.
Please contact your system administrator.
Add correct host key in /Users/a0000/.ssh/known_hosts to get rid of this message.
Offending RSA key in /Users/a0000/.ssh/known_hosts:2
Host key for github.com has changed and you have requested strict checking.
Host key verification failed.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

이런 무서운 메시지가 떴다..해결책을 검색해보니 중간자공격(MITM)이라는 정처기 공부 때 자주 보던 보안 용어가 있어서 해킹인가 싶었는데
중간에 누군가 접속하려는 호스트를 흉내내며 접속을 가로챈 경우를 나타내기 때문이다. github 측에서 host key 가 바뀌었다는 내용이 게재되었다고 하는데 해킹 가능성은 낮다고 한다.

Try Catch 2.

1, .ssh/known_hosts 와 같이 관련된 내용을 갱신해주기

$ ssh-keygen -R github.com
: << 'END'
github rsh host key 관련 문제임으로
END

계속 이런 에러가..뜨는데

$ git status 
#git status 를 쳐 지금 어떤 상태인지 쳐봤고,
On branch master
Your branch is ahead of 'origin/master' by 2 commits.
  (use "git push" to publish your local commits)
#master 에 2개 커밋할게 있다고하고, push 를 사용하라 해서 해봄.

push 와 pull master origin 을 해봤지만 여전히 아래 에러 메세지가 뜸..심지어 fatal

저 에러메시지에서 hint 부분을 단서로 검색을 다시함.
### 원격저장소 에러 메시지

### Try Catch 3.

  1. 현재 연결된 주소를 해제 후 재연결을 해준다.
  • 기존 원격 저장소 연결 삭제
  • $ git remote remove origin # 다시 연결 $ git remote add origin 깃헙주소/***.햣 # 깃헙 주소 확인 $ git remote -v

마지막!! 테스트로 xcode 파일 아무거나 생성하고 푸시 해봄.

우선 fetch(원격에 있는것 로컬에 적용하라는 의미)
그래서 pull origin master 함..

결론 : 에러의 원인

내가 원격에서 변경된 내용을 뭔가 fetch ( 로컬로 적용시키지 않고 ) 내 로컬에서의 브랜치 내용과 충돌해서 push 가 안되었고,
두번째로는 rsh github 인증서 변경과 관련된 에러 같았다.

 


그 외 터미널 명령어

ip 주소 파악

$ ifconfig | grep inet