Skip to main content

How to Use git pull (Including Origin/Master)

Short answer

git pull origin master fetches the latest commits from the master branch on the origin remote and merges them into your current local branch in a single step. It is equivalent to running git fetch origin followed by git merge origin/master. If your team has renamed the default branch to main (now the GitHub default), the command becomes git pull origin main. Once you have configured a tracking relationship between your local branch and the remote (via git push -u or git branch --set-upstream-to), you can shorten this to simply git pull with no arguments. Always ensure your working directory has no uncommitted changes before pulling, as an automatic merge can create conflicts that are easier to resolve from a clean state.

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:

  1. It updates the current local working branch (the branch currently checked out).
  2. 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. 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!

Free. We email you a ZIP with our cheat sheets.


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". Use --rebase to replay your local commits on top of the remote changes instead:

git pull origin master --rebase

Use --no-ff to force a merge commit even when a fast-forward would be possible — useful when you want to preserve a record that a merge occurred:

git pull origin master --no-ff

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 the Inspecting Remote Data – Desktop GUI edition chapter of our free online book.


No Command Line Needed

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

Free download

Download the Cheat Sheet

Get 18 of our most popular Cheat Sheets in one handy ZIP!