Fetching & Pulling

How to safely download your team's changes, and the crucial difference between fetching and pulling.

Version Control6 min readConcept 16 of 29

git pull = fetch + merge

git fetch is a safe command that only downloads data (commits, branches, and tags) from a remote repository. It updates your remote-tracking branches (like origin/main), but it does **not** touch your local working files.

git pull is an aggressive command. It runs git fetch to download the data, and then immediately runs git merge to combine that data into your current working branch.

Why it matters

When working on a team, the remote repository is constantly moving forward as teammates push their work.

To see their work, review their code, or integrate their features with your own, you must bring that data down to your local machine. Understanding the difference between fetch and pull prevents you from accidentally triggering unwanted merge conflicts.

How it works

When you run git fetch, Git communicates with the remote server, grabs all the commits you don't have, and stores them locally. Your working directory remains unchanged. You can inspect the new commits safely.

When you run git pull, Git fetches that same data, but then attempts to merge it into whatever branch you are currently on. If your local work conflicts with the pulled work, the pull will halt with a merge conflict.

Check yourself

Pick an answer to lock it in, then read why. Getting one wrong is part of how it sticks.

  1. 1What two Git commands are executed sequentially when you run `git pull`?
  2. 2Why is `git fetch` considered a 'safe' operation compared to `git pull`?
  3. 3What is the most common reason Git will abort a `git pull` command?

Remember this

  • git pull = git fetch + git merge.
  • git fetch safely downloads data without touching your files.
  • Always commit or stash your work before running git pull.

Done with this concept?

Mark it complete to track your progress. No login needed.