Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags


What is the git push -u <remote> <branch name> command?

Talha Ashar

The git push -u <remote> <branch name> command uploads content from a local repository to a remote repository. It is generally used to upload modifications in a local repository with remote team members.

The process is illustrated below:


The options in the git push -u <remote> <branch name> command are described as follows:

  • -u: The -u flag creates a tracking reference for every branch that you successfully push onto the remote repository. The local branch you push is automatically linked with the remote branch. This allows you to use commands such as git pull without any arguments.

  • <remote>: The <remote> option specifies the name of the remote repository to which the changes need to be pushed. If you clone a repository, the name of the remote repository is saved under the name origin on your local system. Alternatively, you can provide the URLUniform Resource Locator of the repository as well.

  • <branch name>: The <branch name> option specifies the remote repository branch to which the changes need to be pushed.


The code below shows an example of how to push changes between a local and remote repository:

git push -u master

The above command pushes the changes from your local branch to the master branch of the example repository.

Since the -u flag is used, your local branch is automatically linked to the master branch. Therefore, whenever you need to pull changes from the master branch, you can use the command git pull without any arguments.

For more details and variants of the git push command, you can check the official documentation.




Talha Ashar
Copyright ©2023 Educative, Inc. All rights reserved

View all Courses

Keep Exploring
Related Courses