닭발개발

[Git 오류] Updates were rejected because the tip or your current branch is behind its remote.. 본문

Git

[Git 오류] Updates were rejected because the tip or your current branch is behind its remote..

D269 2023. 5. 22. 11:31
728x90

 

계속 push를 하려고하면

 

 git push --set-upstream origin master

 

을 치라고 나오고, 그래서 똑같이 치면

 

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.

 

라고 나와서 당황했는데 찾아보니까 원인은 두가지였다.

 

 

1. Git Repository를 생성할 때 Readme.md 파일을 생성해서 생기는 오류

2. 나처럼 이미 푸시해놓은 파일이 있어서라던가 데이터 유실 등 문제가 있을 수 있는 부분이 있어

   git에서 처리 되지 않도록 에러를 띄우는 것

 

이라고 한다.

 

근본적인 원인을 찾아서 해결하면 좋겠지만 임시방편의 해결책으로 +를 사용하면 바로 해결할 수 있다.

 

git push -u origin +master

또는

 

git push origin master -f

를 해도 된다!

 

-f는 force, 강제로 한다는 뜻!

 

 

 

짠! 해결 되었다 :D

 

 

** 대신 이 방법을 쓰면 기존에 커밋했던 코드 및 파일들은 모두 유실될 수 있으니 주의! **

 

 

 

 

 

 

 

 

출처 : https://seolahchloe.tistory.com/entry/Git-%EC%98%A4%EB%A5%98%ED%95%B4%EA%B2%B0-Updates-were-rejected-because-the-tip-of-your-current-branch-is-behind-its-remote

728x90
반응형

'Git' 카테고리의 다른 글

[Git] fatal: Not a valid object name: 'master'.  (0) 2023.10.12
[Git] 원격 저장소 연결 및 끊기 (git remote)  (0) 2023.08.22
[Git] branch 생성과 전환 방법  (2) 2023.05.22
Git의 시작  (0) 2023.02.24