GitHub
renamed repository
remote error
repository moved
new location

Error with renamed repo in GitHub remote This repository moved. Please use the new location

Master System Design with Codemia

Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.

Introduction

The message "remote: This repository moved. Please use the new location" appears when a GitHub repository has been renamed or transferred to a different owner/organization. GitHub sets up a redirect from the old URL, so git push and git pull may still work temporarily, but the redirect can break at any time and some operations may fail. The fix is to update your local remote URL to the new repository location.

The Error

bash
$ git push
remote: This repository moved. Please use the new location:
remote:   https://github.com/new-owner/new-repo-name.git

Or with SSH:

bash
$ git pull
remote: This repository moved. Please use the new location:
remote:   [email protected]:new-owner/new-repo-name.git

Fix: Update the Remote URL

bash
1# Check current remote URL
2git remote -v
3# origin  https://github.com/old-owner/old-repo-name.git (fetch)
4# origin  https://github.com/old-owner/old-repo-name.git (push)
5
6# Update to the new URL (HTTPS)
7git remote set-url origin https://github.com/new-owner/new-repo-name.git
8
9# Or update to the new URL (SSH)
10git remote set-url origin [email protected]:new-owner/new-repo-name.git
11
12# Verify the change
13git remote -v
14# origin  https://github.com/new-owner/new-repo-name.git (fetch)
15# origin  https://github.com/new-owner/new-repo-name.git (push)
16
17# Test the connection
18git fetch

Finding the New URL

If the error message does not show the new location:

bash
1# Visit the old URL in a browser — GitHub redirects automatically
2# https://github.com/old-owner/old-repo-name → redirects to new URL
3
4# Or use the GitHub API
5gh api repos/old-owner/old-repo-name --jq '.full_name'
6# Returns the current (new) name
7
8# Or check the redirect with curl
9curl -sI https://github.com/old-owner/old-repo-name | grep location
10# location: https://github.com/new-owner/new-repo-name

When This Happens

Repository Renamed

bash
1# Owner renamed "old-repo" to "new-repo"
2# Old: https://github.com/user/old-repo.git
3# New: https://github.com/user/new-repo.git
4
5git remote set-url origin https://github.com/user/new-repo.git

Repository Transferred

bash
1# Transferred from user to organization
2# Old: https://github.com/user/repo.git
3# New: https://github.com/org/repo.git
4
5git remote set-url origin https://github.com/org/repo.git

Username Changed

bash
1# Owner changed their GitHub username
2# Old: https://github.com/old-username/repo.git
3# New: https://github.com/new-username/repo.git
4
5git remote set-url origin https://github.com/new-username/repo.git

Updating All Clones (Team)

If multiple developers have cloned the repo, everyone needs to update their remote:

bash
# Each developer runs:
git remote set-url origin https://github.com/new-owner/new-repo-name.git

For CI/CD pipelines, update the repository URL in:

  • GitHub Actions workflow files (.github/workflows/*.yml)
  • Jenkins, CircleCI, GitLab CI configuration
  • Docker build scripts that git clone
  • Deployment scripts and Terraform modules
  • Any submodule references in .gitmodules

Updating Submodule URLs

If the renamed repo is used as a Git submodule:

bash
1# Edit .gitmodules
2git config -f .gitmodules submodule.path/to/sub.url https://github.com/new-owner/new-repo.git
3
4# Sync the change
5git submodule sync
6
7# Verify
8git submodule status

GitHub Redirect Behavior

GitHub maintains redirects when a repository is renamed or transferred:

  • Web URLs: Redirect permanently (HTTP 301)
  • Git clone/fetch/push: Work via redirect but display the warning message
  • API calls: Return the repo under its new name
  • Redirect lifespan: Redirects last until someone creates a new repository with the old name. If old-owner creates a new repo called old-repo-name, the redirect breaks.
bash
# The redirect can break at any time
# Always update your remotes promptly

Common Pitfalls

  • Relying on the redirect long-term: GitHub's redirect works as a convenience, but it breaks the moment someone creates a new repo with the old name. Update your remote URL immediately after seeing this warning.
  • Only updating fetch or push URL: git remote set-url updates both fetch and push URLs by default. But if they were previously set to different values, verify both with git remote -v.
  • Forgetting CI/CD and deployment configs: Local clones are easy to fix, but CI pipelines, Docker builds, and deployment scripts that hard-code the repository URL will break silently if not updated.
  • Submodule references: .gitmodules stores the absolute URL. After a rename, run git submodule sync to propagate the updated URL to the submodule's actual remote configuration.
  • Hardcoded URLs in documentation and scripts: README badges, installation instructions (git clone ...), and shell scripts that reference the old URL need manual updates. Search the codebase for the old URL.

Summary

  • Update the remote URL with git remote set-url origin <new-url> as soon as you see the warning
  • GitHub redirects from old URLs to new ones, but redirects can break if a new repo takes the old name
  • Renaming, transferring, or changing a username all cause this message
  • Update CI/CD configs, .gitmodules, documentation, and any scripts that reference the old URL
  • Use git remote -v to verify both fetch and push URLs point to the new location
  • Notify team members to update their local clones

Course illustration
Course illustration

All Rights Reserved.