Coding⏱️ 2 min read📅 2026-06-03

How to Fix: How to update a git clone --mirror?

Update a git clone --mirror with git fetch and merge.

Quick Answer: Use `git fetch` to update the mirror clone, then `git merge` to integrate changes from the remote origin.

To keep your git clone --mirror updated with all changes from its remote origin, you need to use a combination of the following commands:

🔍 Why This Happens

  • When you clone a repository using `git clone --mirror`, Git creates a new, shallow copy of the remote repository's history. However, this can lead to issues if you want to keep everything updated, including commits, refs, hooks, and branches.

🛠️ Step-by-Step Verified Fixes

Method 1: Update Mirror Clone

  1. Step 1: Fetch the latest data from the remote repository using `git fetch origin`.
  2. Step 2: Merge the updated data into your local clone using `git merge -s ours --allow-unrelated-histories origin/branch-name` (replace `origin/branch-name` with the actual branch name).

Method 2: Use Git's built-in mirror feature

  1. Step 1: Create a new branch in your local clone using `git checkout -b update-mirror`.
  2. Step 2: Fetch the latest data from the remote repository using `git fetch origin`.
  3. Step 3: Cherry-pick all commits from the remote repository's master branch (or the branch you want to mirror) using `git cherry-pick -X ours --allow-unrelated-histories origin/master..origin/branch-name` (replace `origin/master` and `origin/branch-name` with the actual branch names).

🎯 Final Words

By following these steps, you can keep your git clone --mirror updated with all changes from its remote origin. Remember to replace the branch names and commit hashes with the actual values from your repository.

Did this fix your problem?

If not, try searching for specific error codes.

🔍 Search Error Database

❓ Frequently Asked Questions