Course contentsShow
← Software Engineering
Lesson 76 of 1,9332. Version Control with GitFree lesson

Fetching Changes

Using git fetch to download commits and branches from a remote without merging them.

Fetching Changes

What you'll learn: How to safely download updates from a remote repository without altering your local work.

The Core Idea

When you work with remote repositories, other team members continuously push new commits and branches. To see what's changed on the remote without immediately merging those changes into your own branches, you use git fetch.

Think of git fetch like checking your mailbox. You retrieve all the new mail (commits) and see what arrived, but you don't have to open or act on anything immediately. The letters sit safely in your mailbox until you're ready to read them.

How It Works

When you run git fetch, Git contacts the remote repository (like origin) and downloads:

  • New commits that don't exist in your local repository
  • New branches created on the remote
  • Updates to existing remote branches

These updates are stored as remote-tracking branches in your local repository (like origin/main or origin/feature-login). Your own local branches (main, feature-login) remain completely untouched.

Why This Matters

Fetching gives you a safe preview of what's new before you integrate changes. You can:

  • Review what commits others have made
  • See new branches without switching to them
  • Decide when and how to incorporate remote changes (merge, rebase, or not at all)

This separation between downloading and integrating gives you control and prevents unexpected disruptions to your current work.

Key Takeaway: git fetch downloads commits and branches from a remote repository to your local machine, updating your view of what's on the remote without changing any of your local branches—giving you a safe preview before integrating changes.