반응형
로컬 레파지토리에 새로운 파일을 생성한 후 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 |