git pull

Using the git pull command, you can update your local repository with any changes that have been pushed by other developers since the last time you ran the command.

To use this command, simply type:

$ git pull

The remote version of your current branch will be contacted and any updated code will be merged into your local copy.

This will use the default configured remote (normally named origin) but if one hasn't been configured, or you want to pull from a specific branch and/or remote, you can specify them:

$ git pull origin main

Name the remote first and the branch second. Unlike git fetch, which just downloads the latest updates from the repository, git pull will actually try to merge the code into your local copy so your working files will be changed.

We have a guide explaining the differences in more detail in our FAQs.

Pull with rebase

By default, git pull creates a merge commit when combining the remote changes with your local work. If you'd prefer a cleaner, linear history, you can rebase your local commits on top of the remote changes instead:

$ git pull --rebase origin main

This replays your local commits after the fetched changes, avoiding unnecessary merge commits. It's particularly useful when working on a shared branch where multiple developers push frequently.

To make rebase the default behaviour for git pull, you can set it in your Git config:

$ git config --global pull.rebase true

Fast-forward only

If you want to ensure that git pull only succeeds when your branch can be fast-forwarded (i.e. you have no local commits that diverge from the remote), use:

$ git pull --ff-only

This is a safe option when you want to avoid accidental merges or rebases. If the branches have diverged, the command will fail with an error, giving you the chance to decide how to proceed.

Handling conflicts during pull

When your local changes overlap with changes on the remote, Git will pause the merge and mark the conflicting files. You'll see something like:

Auto-merging index.html
CONFLICT (content): Merge conflict in index.html
Automatic merge failed; fix conflicts and then commit the result.

Open the affected files, look for the conflict markers (<<<<<<<, =======, >>>>>>>), and edit them to keep the correct version. Once resolved, stage the files and complete the merge:

$ git add index.html
$ git commit

For a detailed walkthrough, see our guide on resolving merge conflicts.

Common errors

"Your local changes would be overwritten by merge" — You have uncommitted changes that conflict with the incoming code. Either commit your work, stash it with git stash, or discard the changes before pulling.

"There is no tracking information for the current branch" — Your local branch isn't linked to a remote branch yet. Specify the remote and branch explicitly: git pull origin main.


Once your local copy is up to date, DeployHQ can automatically deploy the latest changes to your server whenever you push — no manual steps required.