[Github] ! [rejected] master -> master (non-fast-forward) error: failed to push some refs to ~

Ko Hyejung·2021년 4월 3일
0

Github

목록 보기
1/2
post-thumbnail

Github push 실행 중 마주치는 에러!

**! [rejected]        master -> master (non-fast-forward)**
error: failed to push some refs to ~
hint: Updates were rejected because the tip of your current branch is behind
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.

해결 > git pull origin master --allow-unrelated-histories

From https://github.com/gabie0208/comsil_5_github
 * branch            master     -> FETCH_HEAD
Merge made by the 'recursive' strategy.
 LinkedList.h | 98 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 Makefile     | 18 +++++++++++
 Stack.h      | 24 +++++++++++++++
 main.cpp     | 65 ++++++++++++++++++++++++++++++++++++++++
 4 files changed, 205 insertions(+)
 create mode 100644 LinkedList.h
 create mode 100644 Makefile
 create mode 100644 Stack.h
 create mode 100644 main.cpp

이후 다시 push > git push -u origin master

Enumerating objects: 6, done.
Counting objects: 100% (6/6), done.
Delta compression using up to 8 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (5/5), 522 bytes | 522.00 KiB/s, done.
Total 5 (delta 1), reused 0 (delta 0)
remote: Resolving deltas: 100% (1/1), completed with 1 local object.
To https://github.com/gabie0208/comsil_5_github.git
   6c478e5..68cd8eb  master -> master
Branch 'master' set up to track remote branch 'master' from 'origin'.
hyejungko@hyejungcBookPro ss2 % git status
On branch master
Your branch is up to date with 'origin/master'.

push가 성공적으로 실행되었음을 확인할 수 있다!

< 오늘 배운 점 >

  • push 전에 반드시 pull
  • 필요하다면 merge
  • $ git push origin +master 명령어는 가급적 쓰지 않는다. 기존 데이터가 날아갈 위험이 있다. 실제로 해본 결과, 다른 commit msg인 파일은 다 사라졌다...ㅎㅎㅎ

0개의 댓글