git fetch vs git pull: what's the difference?

git fetch downloads new commits from GitHub into origin/main but leaves your branch and files alone. git pull does a fetch and then merges origin/main into your branch.

Step by step

  1. Download the news, change nothing:

    $ git fetch
  2. See what changed on GitHub:

    $ git log main..origin/main
  3. Merge it into your branch:

    $ git merge origin/main
  4. Or do both at once:

    $ git pull

origin/main is your computer's memory of GitHub's main. It only moves when you fetch, pull or push.

Try it in the interactive sandbox →Practice “Pull” with a real repository and teammates, right in your browser.

Related guides