push 는 업로드, push rejection 은 history 보호
git push origin feature/x 는 local branch feature/x 의 commit 을 remote 의 feature/x 로 업로드. 새 branch 첫 push 엔 tracking 설정용 -u: git push -u origin feature/x. 그 후엔 feature/x 에서 plain git push 가 default 로 맞는 곳으로. Tracking 이 branch 를 양방향으로 흐르는 한 줄 effort 로 만들어.
Push rejection 은 서버엔 있고 local 엔 없는 history 를 덮어쓰지 않으려는 Git 의 거부야. 에러 메시지가 명확: "Updates were rejected because the remote contains work that you do not have locally." 네 일은 거부 우회가 아니라 remote 작업 먼저 통합. git fetch, 그 다음 새 tip 위에 rebase (git rebase origin/feature/x) 또는 merge (git merge origin/feature/x), 다시 push.
Force push 는 가볍게 잡지 말아야 할 비상구야. git push --force 는 commit 잃을지언정 remote branch 를 local history 로 덮어써. 재앙 버전: 다른 사람이 네가 안 받은 작업 push 했는데 force-push 가 그 commit 들을 서버에서 지움. 더 안전한 — 시니어가 쓸 유일한 — 대안은 git push --force-with-lease, 마지막 fetch 이후 remote tip 이 움직였으면 push 거부. 평소엔 똑같고, 위험할 땐 거부.
Muscle memory 로 박아둘 패턴 둘. 첫 push 에 tracking 설정: git push -u origin <branch>. 안전망 있는 rebase force-push: git push --force-with-lease. git config --global push.default current 설정하면 인자 없는 git push 가 항상 현재 branch 를 추적된 remote 로 push — 우발 wrong-branch push 한 부류 제거.