Change Origin of a Git Repository
Change Origin of a Git Repository
Moving a repository to a new host — or renaming it within the same host — is a routine operation. The steps below walk you through the process safely, from updating the remote URL to verifying and pushing your history.
When You Might Need This
- You are migrating from one Git hosting provider to another (e.g. Bitbucket to GitHub).
- Your organisation has changed its GitHub organisation name or domain.
- You are transferring a personal repository to a team account.
Step 1: Update the Remote URL
Replace the origin URL with the new repository address. Use the SSH or HTTPS URL depending on how you authenticate:
git remote set-url origin [email protected]:your-org/new-repo.git
If you are unsure which URL format to use, check your hosting provider's clone instructions — they will show both options.
Step 2: Verify the Change
Before you push anything, confirm that the remote now points where you expect:
git remote -v
This prints both the fetch and push URLs for every remote. You should see origin pointing to your new repository.
You can also test the connection directly:
git remote show origin
This fetches metadata from the remote and displays the branches it knows about. If you see an error here, your URL or credentials are wrong — fix them before continuing.
Step 3: Push Everything
Once the remote is verified, push all local branches and tags to the new origin:
git push --all origin
git push --tags origin
--all pushes every local branch. --tags pushes every tag — important if you use tags for releases or version numbers.
Step 4: Confirm on the Remote
Log into your new hosting provider and verify that all branches and tags are present. Compare the branch list and the most recent commits against your local repository to make sure nothing was missed.
A Note on the Old Origin
The old repository still exists until you delete it. If other developers or CI systems still reference it, update them to point to the new URL as well. Once everyone has migrated, you can archive or delete the old repository.