Git Push

Download Git for free


git push

will push your code to your existing upstream. Depending on the push configuration, it will either push code from you current branch (default in Git 2.x) or from all branches (default in Git 1.x).

Specify remote repository

When working with git, it can be handy to have multiple remote repositories. To specify a remote repository to push to, just append its name to the command.

git push origin

Specify Branch

To push to a specific branch, say feature_x:

git push origin feature_x

Set the remote tracking branch

Unless the branch you are working on originally comes from a remote repository, simply using git push won't work the first time. You must perform the following command to tell git to push the current branch to a specific remote/branch combination

git push --set-upstream origin master

Here, master is the branch name on the remote origin. You can use -u as a shorthand for --set-upstream.

Pushing to a new repository

To push to a repository that you haven't made yet, or is empty:

  1. Create the repository on GitHub (if applicable)
  2. Copy the url given to you, in the form
  3. Go to your local repository, and execute git remote add origin URL
    • To verify it was added, run git remote -v
  4. Run git push origin master

Your code should now be on GitHub

For more information view Adding a remote repository


Push code means that git will analyze the differences of your local commits and remote and send them to be written on the upstream. When push succeeds, your local repository and remote repository are synchronized and other users can see your commits.

For more details on the concepts of "upstream" and "downstream", see Remarks.

Push a specific object to a remote branch