S1U12 Q

이유정·2022년 9월 17일
0

코드스테이츠 TIL

목록 보기
17/62
post-thumbnail

git을 정리하는 것보다, 날 좌절시켰던 push 부분을 이야기해보려 한다.
많은 블로그에서 날 좌절시켰기 때문에 나같은 사람을 위해 올린다.

git push 하는 과정에서
찾아온 문제점
'Updates were rejected because the tip of your current branch is behind'
이걸 구글에 검색해보면, 약간 임시 방편의 강제성? 코드만 제안해준다.
그래도 끈질기게 나는 검색을 계속 하다가,,
(밑 코드는 터미널에서 push 가 실패한 과정)

main$ git push origin main
To github.com:FordangIT/fe-sprint-my-agora-states.git
 ! [rejected]        main -> main (non-fast-forward)
error: failed to push some refs to 'github.com:FordangIT/fe-sprint-my-agora-states.git'
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에 대한 기초가 부족하니 내가 지금 뭘 못하고 있는지 헷갈리는 정도였는데,
이 스택오버플로우의 질문자분도 거의 나와 똑같이 헤매고 계셨다.
내가 얼마나 여러개를 알아보고 시도해봤는지 여기 잘 정리되어있다.
그리고 어떤 부분에서 나는 해결이 됐는지 공유하려고 한다.
이 스택오버플로우가 잘 답변 되어있는 것 같아 올린다.
https://stackoverflow.com/questions/70298479/git-push-updates-rejected-because-tip-of-current-branch-behind-remote-counterp

여기서 제시된 해결책 중, git pull origin main 을 통해 나는 해결이 됐다

main$ git pull origin main
From github.com:FordangIT/fe-sprint-my-agora-states
 * branch            main       -> FETCH_HEAD
Already up to date.

이렇게 나온다. 그 과정에서 git pull이 무엇인지 잘 몰라서 검색했다.
여기 잘 공유되어 있어서 이또한 공유하고 지나간다.
https://kotlinworld.com/288

이렇게 해주고 난뒤, 다시 push 해보니까
commit 드디어 성공!!!

main$ git push -u origin main
Enumerating objects: 7, done.
Counting objects: 100% (7/7), done.
Delta compression using up to 8 threads
Compressing objects: 100% (4/4), done.
Writing objects: 100% (4/4), 431 bytes | 431.00 KiB/s, done.
Total 4 (delta 3), reused 0 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (3/3), completed with 3 local objects.
To github.com:FordangIT/fe-sprint-my-agora-states.git
   0714b52..844428d  main -> main
Branch 'main' set up to track remote branch 'main' from 'origin'.

나의 remote repository 에 커밋을 해줬는데
내가 pull request에 올렸던 내용에도 똑같이 커밋이 올라가있는 것을 볼 수 있었다.

이건 우리 코드스테이츠 스터디 홀에 공유한 부분이다.
스터디원분들이 강제로 push 하는 방법만 알고 끝났길래 올려놨다!!!

profile
팀에 기여하고, 개발자 생태계에 기여하는 엔지니어로

0개의 댓글