git push

Send your commits to the server

What it does

git push sends the new commits of the current branch to the remote. The first time you push a new branch, say where to: git push -u origin <branch>. -u remembers the link, and after that a plain git push and git pull are enough.

If the server has commits you do not, push refuses: get them with git pull first, then push again. After git commit --amend, git reset or git rebase your history differs from the server's, and a plain push fails too.

Careful. --force and --force-with-lease replace the branch on the server with yours, and other people's commits you do not have are lost. Use them only on your own branches, and prefer --force-with-lease: it refuses if the server has commits you have not seen yet.

Syntax

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

Examples

Related commands

Practise · All commands