본문 바로가기
💻CODING/etc.

[git] git 강제 push (ft. 강제 git push의 문제점)

by 코딩하는 갓디노 2021. 11. 29.

강제 git push 명령어

 

강제로 git push 하는
명령어 입니다.

 

강제 git push 하는 명령어

git push -u origin master --force //기존에는 git push origin master

 

여러 컴퓨터에서 한 프로젝트를 동시 진행하다 보니
git push 도중 아래와 같은 에러가 발생했습니다.

error: 레퍼런스를 'https://github.com/...git'에 푸시하는데 실패했습니다
힌트: 리모트에 로컬에 없는 사항이 들어 있으므로 업데이트가
힌트: 거부되었습니다. 이 상황은 보통 또 다른 저장소에서 같은
힌트: 저장소로 푸시할 때 발생합니다.  푸시하기 전에
힌트: ('git pull ...' 등 명령으로) 리모트 변경 사항을 먼저
힌트: 포함해야 합니다.
힌트: 자세한 정보는 'git push --help'의 "Note about fast-forwards' 부분을
힌트: 참고하십시오.

 

 

이런 에러는 보통 git remote branch 코드가 local 코드보다 앞서 있기 때문에 충돌을 피하고자 발생된 에러입니다.
하지만 힌트대로  git pull을 실행하니 또 다른 에러가 출현했습니다. 

힌트: Pulling without specifying how to reconcile divergent branches is
힌트: discouraged. You can squelch this message by running one of the following
힌트: commands sometime before your next pull:
힌트: 
힌트:   git config pull.rebase false  # merge (the default strategy)
힌트:   git config pull.rebase true   # rebase
힌트:   git config pull.ff only       # fast-forward only
힌트: 
힌트: You can replace "git config" with "git config --global" to set a default
힌트: preference for all repositories. You can also pass --rebase, --no-rebase,
힌트: or --ff-only on the command line to override the configured default per
힌트: invocation.
fatal: 관계 없는 커밋 내역의 병합을 거부합니다

 

어쩔 수 없이 강제 git push 처리를 진행하였습니다. 

 

강제 git push의 문제점

강제 push를 진행하면 여러분께서 그동안  repository의 commit 한 기록이 다 삭제되어
1 commit 만 남아 있게 될 수 있습니다.

저의 경험상 50%의 확률로 커밋 기록이 다 사라졌었습니다. 

그동안의 기록 관리가 필요하다면 강제 git push를 추천드리지 않으니 이점 확인하신 후 진행하세요.

반응형

댓글