Git is one of the most widely used version control systems today. All kinds of software development, from tiny projects to production level enterprise products, everything uses Git today.
Although Git is used as a decentralized version control system, i.e., each user can have his/her own version of the code, there is usually a central remote repository where the code is stored. Users can push to this repository and pull from it. Thus developers can share their changes with each other via this central repository.
A Git remote is the remote server/repository where the code is stored centrally. Git stores the URL of this repository, referred to as the ‘remote URL’, corresponding to a name for the remote. The remote for the central repository is quite commonly named as origin
. The URL for origin
is then used whenever changes are required to be pushed or pulled.
To see your Git remote URL, run:
git remote get-url <remote_name>
To change Git remote URL, run:
git remote set-url <remote_name> <new_url>
As we can see, we changed the URL for remote origin
from the Github repository to the Gitlab repository.
Note that the remote origin
should already exist so that set-url
command can change its URL.
To add a new remote, use the git remote add
command. For more information on this and other git remote commands, run git help remote
.
Member discussion