What does git pull origin master do?
git pull
is a Git command that is used to update the local version of a project from a remote repository. It is one of the commands that involve network interaction in Git.
The git pull
command downloads the code that is available from a remote repository (such as GitHub, GitLab, BitBucket, or another code hosting platform) and automatically merges any changes.
By default, git pull
performs two main actions:
- It updates the current local working branch (the branch currently checked out).
- It updates the remote tracking branches for all other branches.
The git pull
command is used in many variations and you can customize it by using different arguments (take a look at our git pull command overview to learn more). But one of the notations that developers find themselves typing most often is git pull origin master
(or main
): it downloads new code from the branch named master
on the remote named origin
and integrates them into your local HEAD branch.
The Git Cheat Sheet
No need to remember all those commands and parameters: get our popular "Git Cheat Sheet" - for free!
Downloading & Integrating with git pull
git pull
will not only download new changes from the remote repository (such as GitHub, GitLab, or BitBucket), but it will also directly integrate them into your local HEAD branch. git pull origin master
is no exception.
By default, this integration will happen through a "merge", but you can also choose a "rebase":
$ git pull origin master --rebase
If you don't want to integrate new changes directly, then you can instead use git fetch
: this will only download new changes, but leave your HEAD branch and working copy files untouched.
$ git fetch origin
Using the Plain git pull Command
In most cases, your local HEAD branch will already have a proper tracking connection set up with a remote branch. This configuration provides default values so that the pull command already knows where to pull from without any additional options. This means that, if a tracking connection has been set up, you can simply omit naming the remote repository and branch:
$ git pull
You can learn more about tracking connections in our free online book.
Tip
Easy Pull & Push in Tower
In case you are using the Tower Git client, pulling from a remote is very easy: simply drag the remote branch and drop it onto your current HEAD in the sidebar - or click the "Pull" button in the toolbar.
Just like pulling, many other Git commands can also be executed with a simple drag-and-drop operation in Tower.
Learn More
- Check out the chapter Inspecting Remote Data in our free online book
- More frequently asked questions about Git & version control