---
title: How to Use git fetch in Git
url: https://docs.vultr.com/how-to-use-git-fetch-in-git
description: Learn how to use git fetch to download remote repository changes without merging them. Discover command options, best practices, and when to use fetch vs pull.
publish_date: 2025-10-10T17:42:58.712778Z
last_updated: 2025-10-15T20:51:40.347000Z
author: Roshan Ray
header_image: https://lhr1.vultrobjects.com/docs-main-doc-assets-1/2339/42ec7ce9-c8d5-44dc-9c11-2a7bf275ad6e.png
---

> Index of every Vultr Docs page in markdown: https://docs.vultr.com/llms.txt

The `git fetch` command lets you review changes from a remote repository without modifying your local branches. It updates the remote-tracking branches and saves the details in `FETCH_HEAD`. After fetching, you can manually merge or rebase those changes into your local repository.

This article explains how to use `git fetch` to update from remote repositories, including specific branches, all remotes, and cleanup tasks.

## The Short Answer Version

If you’re already familiar with Git and need quick reference commands for fetching updates:

```

# Fetch updates from a specific remote
$ git fetch <remote>

# Fetch updates of a specific branch from a remote
$ git fetch <remote> <branch>

# Fetch updates from all remotes
$ git fetch --all

# Remove local references to deleted remote branches
$ git fetch --prune
```

## Common Options for git fetch

The following are some commonly used flags to retrieve updates from remote repositories and manage remote-tracking branches:

| Flags        | Description                                                         |
|--------------|---------------------------------------------------------------------|
| `--all`      | Fetch from all remotes, not only the default remote, for example, `origin`.                              |
| `--prune`    | Remove local references to branches deleted on the remote.    |
| `--dry-run`  | Shows which updates are available without applying them.                |
| `--verbose`  | Display detailed information about the git operation.               |
| `--tags`     | Fetches all tags from the remote along with branches.             |
| `--force`    | Force updates to local references to match the remote, even if it overwrites changes.   |
| `--multiple` | Fetch from more than one remote in a single command.                    |
| `--atomic`   | Either update all references, or none, to avoid partial updates. |

## Fetch All Remote Updates

Use `git fetch` command to retrieve the latest updates from a remote repository. This command shows all branches and commits in the remote repository and updates your remote-tracking branches without merging them into your local branches. It helps you review changes made by collaborators while keeping your local work unchanged until you [choose to merge](https://docs.vultr.com/how-to-merge-branches-in-git) or rebase.

### Command Syntax

```
git fetch <remote>
```

Where `<remote>` is the remote repository you want to fetch changes from (for example, `origin`).

### Command Demonstration

1. Make a change in the remote repository by editing a file or creating a new commit.
1. In your local repository, check the configured remotes.

    ```console
    $ git remote -v
    ```

    It lists all remote repositories by name along with their URLs.

    Output:

    ```
    origin  https://github.com/username/test-repo.git (fetch)
    origin  https://github.com/username/test-repo.git (push)
    ```

1. Fetch updates from the remote repository.

    ```console
    $ git fetch origin
    ```

    It fetches updates from all branches on the `origin` remote and refreshes their remote-tracking branches.

1. Inspect the fetched changes.

    ```console
    $ git log origin/main
    ```

    `git log` displays the commit history of a branch.

    Sample output:

    ```
    commit 8ecb58dbecee84f9fd0b2e0089df7dae63814be4 (origin/main, origin/HEAD)
    Author: username <username@gmail.com>
    Date: Sun Sep 7 22:14:54 2025 +0530

        New Line Added
    ```

1. Merge the new changes

    ```console
    $ git merge origin/main -m "commit message"
    ```

    `git merge` merges the changes you fetched.

## Fetch a Specific Remote Branch

Using `git fetch` with a branch name retrieves updates from a specific remote-tracking branch on the remote repository. This is useful when you only want to review or integrate changes from one feature or topic branch, instead of fetching updates for all branches.

### Command Syntax

```
git fetch <remote> <branch>
```

### Command Demonstration

1. Make changes to a remote branch in your remote repository and commit changes to the remote branch you want to fetch.

1. In your local repository, fetch a specific remote branch.

    ```console
    $ git fetch origin feature-login
    ```

    It fetches updates only from the `feature-login` branch on the `origin` remote and updates your remote-tracking branch `origin/feature-login`.

1. Review the Fetched Branch

    ```console
    $ git log origin/feature-login
    ```

    It shows the commit history of the remote-tracking branch `origin/feature-login`.

1. Merge the remote branch into your local branch

    ```console
    $ git merge origin/feature-login -m "commit message"
    ```

    It merges the changes you fetched from the remote `feature-login` branch into your current local branch.

## Fetch From All Remotes

If your repository has multiple remotes, use the `--all` flag to fetch updates from all of them. This updates each remote-tracking branch so you can review or merge the changes locally.

```console
$ git fetch --all
```

It fetches all changes from each remote and updates their remote-tracking branches so you can review or merge updates into your local branches.

> [!NOTE]
> You can add `--verbose` to see detailed information about which branches and commits are being updated.

## Clean Up Deleted Remote Branches

Sometimes, collaborators may delete branches from the remote repository. Run `git fetch --prune` to clean up stale references and avoid clutter in your branch list.

```console
$ git fetch --prune
```

It removes references to remote branches that no longer exist, without touching your local branches.

## Conclusion

You’ve learned to use `git fetch` to review changes from remote repositories, fetch specific branches, update all remotes, and clean up deleted remote-tracking branches. These commands help you stay updated with collaborators’ work while keeping your local repository safe. For more details and advanced configuration options, refer to the [official Git documentation](https://git-scm.com/docs/git-fetch).
