How to change the URI for a remote Git repository?

· · 3975 views

I have migrated the remote repository to another host, So, I need to change the remote’s URL.

So, please guide how to change the URL of a Git remote?

0
2 Answers

Try this:

# View existing remotes
git remote -v
# origin  https://github.com/user/repo.git (fetch)
# origin  https://github.com/user/repo.git (push)

# Change the 'origin' remote's URL
git remote set-url origin https://github.com/user/repo2.git

# Verify new remote URL
git remote -v
# origin  https://github.com/user/repo2.git (fetch)
# origin  https://github.com/user/repo2.git (push)
0

Use this:

git remote set-url origin git://new.location

Alternatively, open .git/config, look for [remote "origin"], and edit the url = line.

You can check it worked by examining the remotes:

git remote -v
# origin  git://new.location (fetch)
# origin  git://new.location (push)
0

Please login or create new account to participate in this conversation.