How to change the URI (URL) for a remote Git repository? - TechvBlogs

How to change the URI (URL) for a remote Git repository?

In this tutorial, you are going to learn how you can change the URL of a Git remote easily.


Suresh Ramani - Author - TechvBlogs
Suresh Ramani
 

6 months ago

What is Git?

Git is the world's most popular distributed version control system used by many open-source and commercial projects. It allows you to collaborate on projects with your fellow developers, keep track of your code changes, revert to previous stages, create branches, and more. Linus Torvalds (the creator of Linux) developed Git.

Git is software for tracking changes in any set of files, usually used for coordinating work among programmers collaboratively developing source code during software development. Its goals include speed, data integrity, and support for distributed, non-linear workflows.

A version control system is a system that keeps a record of the changes in a file (or multiple files) over a period. This is so that a user may return to a previous version of the system's software whenever necessary.

Features of Git

  • Tracks history.
  • Free and open source.
  • Supports non-linear development.
  • Creates backups.
  • Scalable.
  • Supports collaboration.
  • Branching is easier.
  • Distributed development.

Read Also: How to Install Git On Ubuntu 20.04

What is Git Remote URI(URL)?

Git remote is a pointer that refers to another copy of the repository that is usually hosted on a remote server.

In some situations, like when the remote repository is migrated to another host, you need to change the remote’s URL.

In this tutorial, you are going to learn how you can change the URL of a Git remote easily.

Changing a Git Remote’s URL

Each Git repository can have zero or more Git remotes linked to it. When you clone a repository, the name of the remote is set automatically to origin and points to the repository that you cloned from.

Follow the steps below to change the URL of a remote:

1. Change to the directory where the repository is located:

cd /path/to/repository

2. Run git remote to list the existing remotes and see their names and URLs:

git remote -v

3. Use the git remote set-url a command followed by the remote name, and the remote’s URL:

git remote set-url <remote-name> <remote-url>

If you’re changing to HTTPS, the URL will look something like this:

https://gitserver.com/user/repo_name.git

If you’re changing to SSH, the URL will look like this:

[email protected]:user/repo_name.git

4. Verify that the remote’s URL was successfully changed by listing the remote connections:

git remote -v

That’s it. You have successfully changed the URL of the remote.

Thank you for reading this blog.

Read Also: How to Install OpenLiteSpeed on Ubuntu 20.04

If you want to manage your VPS / VM Server without touching the command line go and  Checkout this linkServerAvatar allows you to quickly set up WordPress or Custom PHP websites on VPS / VM in a  matter of minutes.  You can host multiple websites on a single VPS / VM, configure SSL certificates, and monitor the health of your server without ever touching the command line interface.

Comments (0)

ServerAvatar
Multiple sites on a single VPS/VM/Server Deploy PHP sites on cloud in minutes, simple as that!
ServerAvatar
Generate Free SSL Certificate - SSLForWeb

Generate Free SSL Certificate

  • 90-Day Certificates
  • SSL Monitoring
  • Wildcard Certificates
  • Multiple Domains
  • Certificate Management
  • Expiration Reminders

Comment


Note: All Input Fields are required.