//////
Search

인텔리제이 push 에러

질문 상태
답변 완료
수업일자
분류
오류

질문

깃허브에 푸쉬하려고 하니까 저렇게 에러가 뜹니다.
[master 415d8f3] Main 클래스에서 실행 2 files changed, 4 insertions(+), 3 deletions(-) 10:37:40.493: [java-init-project] git -c credential.helper= -c core.quotepath=false -c log.showSignature=false push --progress --porcelain master refs/heads/master:master error: failed to push some refs to 'https://github.com/ondayary/java-init-project.git' hint: Updates were rejected because the tip of your current branch is behind To https://github.com/ondayary/java-init-project.git hint: its remote counterpart. Integrate the remote changes (e.g. ! refs/heads/master:refs/heads/master [rejected] (non-fast-forward) hint: 'git pull ...') before pushing again. Done hint: See the 'Note about fast-forwards' in 'git push --help' for details.
JavaScript
복사

답변

non-fast-forward 즉, 깃허브에 있는 파일버전과 현재 로컬의 버전이 달라서 발생하는 에러입니다.
그래서 두 가지 방법이 있습니다.
pull 받으신 후 다시 push 하거나
pull 받게 되면 현재 로컬의 변경사항이 사라지로 깃 내용으로 덮어써질 수 있어서 git stash 명령어로 현재 파일변경사항을 보존해야하는대 일단은 좀 더 쉬운 방법인 아래 방법으로 command 에서 실행해보시겠어요?
강제로 로컬 → 깃 으로 푸시하는 방법이있는대(in command)
git push origin +master
Java
복사

master → main 으로 변경

깃 정책으로 노예 관련한 문제로 master라는 이름 대신 main으로 이름이 default 브랜치명이 바뀌었습니다.
그래서 위 과정으로 master에 올리신 다음
깃허브에서 브랜치명을 main으로 변경
intellij에서 브랜치명을 main으로 변경
source tree에서 브랜치명을 main으로 변경
하시고 이제 계속 진행하실 때
git pull // 변경사항 추가 git add . git commit -m “커밋 메시지” git push origin main
Java
복사
으로 진행해주시면 이제 에러 없이 잘 진행될 것 입니다.

ps

인텔리제이나 소스트리가 어려우시다면 git bash로 진행해주셔도 무방합니다!
git bash가 할 수 있는 일이 더 많고 구글링하면 거의 git bash로 나와서
초기엔 bash로 git명령어 공부하시는 것도 좋습니다!