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
Or with SSH:
Fix: Update the Remote URL
Finding the New URL
If the error message does not show the new location:
When This Happens
Repository Renamed
Repository Transferred
Username Changed
Updating All Clones (Team)
If multiple developers have cloned the repo, everyone needs to update their remote:
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:
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-ownercreates a new repo calledold-repo-name, the redirect breaks.
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-urlupdates both fetch and push URLs by default. But if they were previously set to different values, verify both withgit 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:
.gitmodulesstores the absolute URL. After a rename, rungit submodule syncto 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 -vto verify both fetch and push URLs point to the new location - Notify team members to update their local clones

