·터미널 명령어

git push

git

쓰는 꼴

git push [-u] [--force-with-lease] <remote> <branch>

내 커밋을 원격으로 올립니다 — --force는 원격 브랜치를 덮어써 남이 올린 커밋까지 지울 수 있으니, 원격이 움직였으면 거절하는 --force-with-lease를 씁니다.

자주 쓰는 옵션

옵션
-uset the upstream so later pushes need no arguments
--force-with-leaseforce, but stop if the remote moved since your last fetch
-fforce: overwrite the remote branch, commits of others included
--tagspush tags as well, which push does not do on its own
--delete <branch>delete the branch on the server
--allpush every local branch
-ndry run

예시

git push -u origin feature/login

publishes the branch and remembers the pairing

git push --force-with-lease

the safe force, used after a rebase

git push origin --delete old-feature

removes the branch on the server

되돌리는 방법이 여럿이라 헷갈립니다 — 가리키는 곳을 옮기는 것과 새 커밋을 얹는 것은 다릅니다.

읽는 방법

  • 대괄호 [ ]는 넣어도 되고 안 넣어도 되는 자리입니다.
  • 점 셋 …은 여러 개를 이어 쓸 수 있다는 뜻입니다.
  • 옵션은 대소문자를 가립니다 — -r과 -R이 다른 명령도 있습니다.

자주 묻는 것

Q. git push은 무엇을 하나요?

내 커밋을 원격으로 올립니다 — --force는 원격 브랜치를 덮어써 남이 올린 커밋까지 지울 수 있으니, 원격이 움직였으면 거절하는 --force-with-lease를 씁니다.

Q. 어떻게 치나요?

git push [-u] [--force-with-lease] <remote> <branch> — 대괄호는 생략할 수 있는 자리입니다.

Q. 옵션은 몇 개나 자주 쓰나요?

여기 정리한 것은 7개입니다. 전체 목록은 man git에 있습니다. 이 명령은 git 갈래입니다.

같이 보는 명령

man 페이지: man git-push