[Git] Send local commits to a remote with git push

Created on November 30, 2026

git push sends commits to a remote repository and updates its branch so other people can fetch them.

Push a local branch

The following command pushes the local master branch to master on origin.

git push origin master

Use HEAD to push the currently checked-out branch to a same-named branch.

git push origin HEAD

Set the upstream branch

On the first push of a new branch, use -u to set its upstream.

git push -u origin feature-branch

With the usual same-name push configuration and an upstream set, you can use the shorter command for subsequent pushes.

git push

If Git rejects a non-fast-forward push, fetch and inspect the remote changes. Integrate them before trying again.

Reference

Git