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

How to Fix: Remote rejected (shallow update not allowed) after changing Git remote URL

Git error message explanation and solution.

Quick Answer: The issue occurs because the local repository is still tracking the old remote URL, causing a shallow update. To fix it, run `git fetch` to update the local repository, then `git reset --hard origin/master` to reset the local branch to match the new remote.

When you change the remote URL in Git from your local computer to a new remote, such as BitBucket, and then try to push your project, you may encounter the 'shallow update not allowed' error. This occurs because the new remote has a different commit history than your local repository.

💡 Why You Are Getting This Error

  • Git is designed to maintain a linear commit history, and when you update the remote URL, Git detects that there are divergent branches in your repository.

🔧 Proven Troubleshooting Steps

Method 1: Resetting the Remote Branch

  1. Step 1: Run `git remote set-url origin ` to update the BitBucket URL.

Method 2: Reinitializing the Repository

  1. Step 1: Run `git remote set-url origin ` to update the BitBucket URL.
  2. Step 2: Run `git fetch --force` and then `git reset --hard HEAD` to reinitialize your local repository.

🎯 Final Words

To resolve the 'shallow update not allowed' error after changing the Git remote URL, try resetting the remote branch or reinitializing your local repository. This will ensure that your local repository is updated with the latest changes from the new remote.

Did this fix your problem?

If not, try searching for specific error codes.

🔍 Search Error Database

❓ Frequently Asked Questions