Git push 에러(Updates were rejected because the tip of your current branch is behind its remote..)

삽질/트러블슈팅 2023. 3. 28. 00:46
728x90
728x90

hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

push시에 위와 같은 에러가 발생했다.

push 전 pull을 통해 리파지토리의 최신 상태를 유지한 상태에서 push 해야하는데 그렇지 않았을 경우(리파지토리 생성 시 readme.md를 생성했을 때 포함) 발생하는 에러.

위의 힌트처럼 pull을 진행한 뒤 푸시를 해도 다른 에러가 발생하여 해당 에러를 또 해결하는 과정을 거쳐야 한다고 한다. 그래서 강제로 push처리 해주었다.

 

강제 push는 권장하지 않는 사항이라고 한다.
git pull origin branch --allow-unrelated-histories를 사용하자.

 

아래 그림처럼 push +branch 로 강제 푸시 해주었다.

 

728x90
300x250
mag1c

mag1c

2년차 주니어 개발자.

방명록