How to change URL or Path of remote Git repository

Sometime when we work in git, there are more possibility to change the URL or path of remote git repository, right ?

So in this article, we will learn how to make these changes with a simple git stated command line interpreter.

Try this ,

$ git remote -v        # View existing remote repository
# origin  https://github.com/demo/samplerepo.git (fetch)
# origin  https://github.com/demo/samplerepo.git (push)

Now replace with the new URL

$ git remote set-url origin https://github.com/demo/samplerepo1.git
# Change the 'origin' remote's URL

Validate the new URL or Path

$ git remote -v
# Verify new remote URL
# origin https://github.com/demo/samplerepo1.git (fetch)
# origin https://github.com/demo/samplerepo1.git (push)
Avatar

About Shachindra Yadav

I, Shachindra Yadav, a Cloud Certified, DevOps and technology enthusiastic person, more passionate to learn and write blogs in my free time.

View all posts by Shachindra Yadav →