git push

git push uploads your local commits to a remote repository like GitHub, sharing your work with others. It sends the commits on your current branch to the matching branch on the remote.

Git & DevOps

You can only push commits that have already been made locally — push moves history that exists, it doesn't save uncommitted changes.

The first time you push a new branch, add -u (or --set-upstream) so Git remembers the link, letting you just type git push afterward.

Syntax

git push origin <branch>

Examples

Bash

git push -u origin main

Output:

Enumerating objects: 5, done.
To https://github.com/you/repo.git
   9f3a21c..4b8c7d2  main -> main
branch 'main' set up to track 'origin/main'.

Learn it in a lesson

See also

Back to the Dictionary