Git&Linux

(Git) 업로드 에러 대처법

lastdove 2024. 9. 20. 16:40

Git 명령어

1. 기본설정

  • git config --global init.defaultBranch main : 기본 브랜치 main으로 설정
  • git config --global user.name "username" : 깃허브 닉네임 연동
  • git config --global user.email "username@gmail.com" : 깃허브 이메일 주소 연동

 

2. 에러 대처법

  • Not possible to fast-forward, aborting 에러
    • git pull --rebase : rebase 옵션으로 pull 진행
    • git add (파일명) > git commit -m "메시지" > git rebase --continue : conflict가 발생한 파일을
      수정 후 rebase로 마무리 한다
    • 다시 git push origin main

 

3. IntelliJ Branch master > main 으로 변경 방법

  • git branch -m master main
  • git fetch origin
  • git branch -u origin/main main

 

4. 강제 push 방법 (git 저장소에 로컬자료 덮어씌움)

  • git push origin +main : 자신이 가진 자료가 최종자료일때에만 사용할 것. 덮어씌우기 때문에 깃허브에 업로드된 기존 자료가 손상됨.