push 해주려는데 오류떴당,,,
fatal: No configured push destination.
Either specify the URL from the command-line or configure a remote repository using
후에 이렇게 떴당,,
git remote add <name> <url>
and then push using the remote name
git push <name>
그래서 그대로 git remote add origin http어쩌고~
시도했는데
또 오류뜸,,,
fatal: The current branch main has no upstream branch.
To push the current branch and set the remote as upstream, use
git push --set-upstream origin main
라고 뜨길래 그대로 시도했더니 또 오류뜸!
! [rejected] main -> main (fetch first)
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
힌트에 pull하라길래 단순히 git pull 하고 다시 push 했더니 똑같은 오류
fatal: The current branch main has no upstream branch.
To push the current branch and set the remote as upstream, use
git push --set-upstream origin main
으악 어쩌라는거지 뭐가 문제였을까 하고 구글링 하던 중 원격 저장소 이름을 언급해주지 않아서 발생했다는 것을 알게 되었고, 따라서 git remote -v 로 현재 저장된 원격 저장소 찾은 뒤 원격저장소 명시하면 해결된다했다.
git remote -v
git push origin main
를 실행했는데 야호! 또 오류떴다 ㅎㅎㅎㅎㅎ
! [rejected] main -> main (non-fast-forward)
그래서 이건 뭔데요,,,,,,, 그래서 구글링 하던 중에
강제 push 할 수 있다는 코드를 보고 git push -u origin +main
로 강제 푸쉬 해버림 ㅎㅎㅎㅎ 그 결과
원인으로는
깃헙에 생성된 원격 저장소와 로컬에 생성된 저장소 간 공통분모가 없는 상태에서 병합하려는 시도로 인해 발생.
기본적으로 관련 없는 두 저장소를 병합하는 것은 안되도록 설정되어 있다.
깃허브 repository에는 파일이 삭제됐지만 기존에 남아있는(Pull Request)파일에는 해당 파일이 남아있어서 충돌이 되는게 원인이 된거같다.
새로운 원격저장소를 만들고 로컬 저장소와 연동할 때 git pull 말고 git pull origin main
명령어를 사용해야 한다.
빠뜨렸을 때, git pull origin main --allowed-unrelated-histories
명령어를 통해 원격저장소와 로컬 저장소 병합을 허용한다.
브랜치 명령 앞에 +를 추가해서 push 한다.
git push origin +main
혹은
git branch -M main 하고,
git push -u origin main 명령어 입력하니까 수행함!