Back
GitoryxGitoryx

Git Pull: Sync Your Branch with the Remote

git pull keeps your local branch in sync with the remote. This tutorial explains what pull actually does (fetch + merge or rebase), when to prefer git fetch, and how to handle conflicts that arise during a pull.

Beginner8 min readUpdated

On this page

What is git pull?

git pull is a shortcut for git fetch followed by git merge (or git rebase). It downloads new commits from the remote and integrates them into your current local branch.

The short version

  1. 1Commit or stash local changes first
  2. 2Run git pull to fetch and merge
  3. 3Or git pull --rebase for a linear history
  4. 4If conflicts occur: resolve, git add, git commit

Why it matters

A teammate pushed new commits. You run git pull and end up with a merge commit in your history that you didn't expect, or worse, a conflict that you don't know how to handle.

git pull is how you stay in sync with your team. But it does more than just download code: it also merges (or rebases) the remote changes into your local branch. Understanding what it does under the hood saves you from unexpected merge commits and conflicts.

Where it usually goes wrong

  • Running git pull without understanding it also merges
  • Getting a merge conflict on pull and not knowing how to resolve it
  • Pulling into a dirty working directory with uncommitted changes
  • Not knowing the difference between git pull and git fetch

Git pull, step by step

  1. Step 1: Pull the latest changes from origin

    The simplest use: update your current branch from its tracked remote branch.

    Terminal
    git pull

    Tip: Make sure you're on the right branch before pulling. Run git branch to confirm.

  2. Step 2: Pull from a specific remote and branch

    Explicitly specify remote and branch when you want to pull from something other than the default.

    Terminal
    git pull origin main
  3. Step 3: Pull with rebase instead of merge

    By default, git pull creates a merge commit. Using --rebase re-applies your local commits on top of the incoming ones, giving you a linear history.

    Terminal
    git pull --rebase origin main

    Tip: Set rebase as the default pull strategy: git config --global pull.rebase true

  4. Step 4: Fetch first, then review before merging

    If you want to see what's on the remote before integrating it, use git fetch and inspect the diff first.

    Terminal
    git fetch origin# See what's new on the remotegit log origin/main..HEAD  # your local commits not on remotegit log HEAD..origin/main  # remote commits not on your local# Now merge when readygit merge origin/main
    In Gitoryx: See how many commits you're behind origin at a glanceHow it works
  5. Step 5: Handle a conflict during pull

    If there's a conflict, Git pauses the merge and marks the conflicted files. Resolve them, stage the files, then complete the merge.

    Terminal
    git pull# CONFLICT (content): Merge conflict in src/app.ts# Edit the file to resolve the conflict, then:git add src/app.tsgit commit

    Careful: Don't run git pull with uncommitted changes: Git may refuse or produce unexpected results. Commit or stash first.

  6. Step 6: Abort a pull mid-conflict

    Changed your mind? You can abort the in-progress merge and return to the pre-pull state.

    Terminal
    git merge --abort

Mistakes to avoid with git pull

Pulling with uncommitted local changes
Git may refuse the pull, or partially apply changes leading to a confusing state.
Fix: Commit your work or stash it (git stash) before pulling.
Accumulating merge commits from `git pull`
Every pull creates a 'Merge branch main of origin/main' commit, cluttering the history.
Fix: Use git pull --rebase to integrate remote changes without merge commits.
Confusing `git fetch` with `git pull`
git fetch is safe: it only updates remote tracking branches. git pull fetches AND integrates, potentially creating conflicts.
Fix: Use git fetch when you want to inspect changes first, git pull when you're ready to integrate.

Git pull in Gitoryx

Gitoryx shows you exactly how far your branch is behind origin before you pull, and lets you choose to pull with merge or rebase from the toolbar.

  • See how many commits you're behind origin at a glance
  • One-click pull with merge or rebase option in the toolbar
  • Visual conflict resolution when a pull triggers a conflict
  • Fetch all remotes with a single button: inspect before merging

Free plan · no account required · macOS, Windows and Linux

Git pull: frequently asked questions

What is the difference between `git pull` and `git fetch`?
git fetch downloads remote changes and updates remote tracking branches (like origin/main) but does not touch your local branch. git pull does a fetch then automatically merges (or rebases) into your current branch.
How do I pull without creating a merge commit?
Use git pull --rebase. This re-applies your local commits on top of the remote commits, resulting in a linear history with no merge commit.
What should I do if `git pull` causes a conflict?
Open the conflicted files, resolve the conflict markers (<<<<<<<, =======, >>>>>>>), stage the resolved files with git add, and then run git commit to complete the merge.
Can I pull a branch I'm not currently on?
Not directly. You need to switch to that branch first, then pull. Alternatively, use git fetch to update the remote tracking branch without switching.
All Git tutorials →
Gitoryx

Stop fighting Git. Start shipping.

Download the fast, native Git client that developers actually enjoy using.

v1.1.0 · macOS 12+ (Apple Silicon or Intel) · Windows 10+ · Linux x86_64