[git] git push reject error 해결

2020. 11. 24. 14:41·Programming/Git
반응형

로컬 레파지토리에 새로운 파일을 생성한 후 git에 올리려고 하는데 다음과 같은 에러가 발생했다. 

$ git push origin master
To https://github.com/XXXXXX/XXXXXXX.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/XXXXXX/XXXXXXX.git'
hint: Updates were rejected because the tip of your current branch is
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

 

거절당한 사유를 보면 현재 브랜치의 팁(?) 이 원격 저장소의 뒤에 있어서 그렇다고 하는데...

이유는 pull을 먼저 해서 로컬 저장소와 git의 상태가 동일해야 하는데 그렇지 않아서 그런것 같았다. 

 

그런데 git pull origin master를 해도 해결이 되지 않았다. 

 

그럴 때 뒤에 --rebase 옵션을 추가하면 제대로 pull이 진행되면서 push또한 성공한다. 

$ git pull origin master --rebase
From https://github.com/XXXXXX/XXXXXXXX
 * branch            master     -> FETCH_HEAD
Successfully rebased and updated refs/heads/master.

$ git push origin master
Enumerating objects: 4, done.
Counting objects: 100% (4/4), done.
Delta compression using up to 4 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 1.76 KiB | 601.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
To https://github.com/eunjikeam/python-syntax.git
   82f6e27..16ab411  master -> master

--rebase의 의미를 좀 더 찾아보긴 해야할 것 같은데... merge의 개념이랑 비슷한 느낌이다 . 

원격 HEAD의 맨 위에 로컬 커밋을 rebase 한다고 하는데 아직 내 머리로는 이해 불가...😵

다음에 좀 더 정확히 알면 이와 관련해서도 포스팅 해봐야겠다. 

 

일단 해결!

 

참고 사이트

 

error: failed to push some refs to 'https://github.com/XXXXXXXXX.com

$ git push -u origin master To https://github.com/XXXXXXXXX.com/FirstRepo.git ! [rejected] master -> master (non-fast-forward) error: failed to push some refs to 'https://github.com/XXXX...

stackoverflow.com

 

반응형

'Programming > Git' 카테고리의 다른 글

[Git] warning : LF will be replaced by CRLF in ~~.The file will have its original line endings in your working directory  (0) 2020.11.26
[Git] .gitignore 설정하기  (0) 2020.11.26
[Git] git commit 취소하기, git commit 수정하기  (0) 2020.11.20
[Git]Git add 명령어 되돌리기  (0) 2020.11.20
[Git] git bash 한글이름 파일 깨짐 해결  (0) 2020.11.19
'Programming/Git' 카테고리의 다른 글
  • [Git] warning : LF will be replaced by CRLF in ~~.The file will have its original line endings in your working directory
  • [Git] .gitignore 설정하기
  • [Git] git commit 취소하기, git commit 수정하기
  • [Git]Git add 명령어 되돌리기
자동화먹
자동화먹
많은 사람들에게 도움이 되는 생산적인 기록하기
    반응형
  • 자동화먹
    자동화먹의 생산적인 기록
    자동화먹
  • 전체
    오늘
    어제
    • 분류 전체보기 (144)
      • 생산성 & 자동화 툴 (30)
        • Notion (24)
        • Obsidian (0)
        • Make.com (1)
        • tips (5)
      • Programming (37)
        • Python (18)
        • Oracle (6)
        • Git (13)
      • AI Study (65)
        • DL_Basic (14)
        • ML_Basic (14)
        • NLP (21)
        • Marketing&Recommend (4)
        • chatGPT (0)
        • etc (12)
      • 주인장의 생각서랍 (10)
        • 생각정리 (4)
        • 독서기록 (6)
  • 블로그 메뉴

    • 홈
    • 태그
    • 방명록
  • 링크

  • 공지사항

  • 인기 글

  • 태그

    기초
    python기초
    git commit
    데이터베이스
    GPT
    딥러닝
    Python
    Google Cloud Platform
    nlp
    Github
    빅데이터
    파이토치로 시작하는 딥러닝 기초
    데이터분석
    LSTM
    seq2seq
    ML
    Jupyter notebook
    노션
    dl
    git
    노션첫걸음
    머신러닝
    자연어처리
    Transformer
    pytorch
    notion
    빅데이터분석
    cnn
    파이토치
    gcp
  • 최근 댓글

  • 최근 글

  • hELLO· Designed By정상우.v4.10.3
자동화먹
[git] git push reject error 해결
상단으로

티스토리툴바