Git far off is a pointer that alludes to another duplicate of the archive that is generally facilitated on a distant worker.
In certain circumstances, similar to when the far off vault is relocated to another host, you have to change the far off's URL.
This guide discloses how to change the URL of a Git far off.
Also Read:- What is the difference between github and gitlab and bitbucket
Changing a Git Remote’s URL
Every Git archive can have at least zero Git controllers connected to it. At the point when you clone an archive, the name of the distant is set naturally to inception and focuses to the vault that you cloned from. On the off chance that you made the store locally, you can add another far off .
Also Read:- List of Top Mobile Apps Develop In React Native
The far off can highlight a storehouse facilitated on a Git facilitating administration, for example, GitHub, GitLab, and BitBucket or your private Git worker .
Follow the means underneath to change the URL of a distant:
Change to the registry where the vault is found:
cd /path/to/repository
Run git far off to list the current controllers and see their names and URLs:
git remote -v
The yield will look something like this:
origin https://github.com/user/repo_name.git (fetch)
origin https://github.com/user/repo_name.git (push)
Also Read:- What is difference between Node.JS and Express.JS?
Utilize the git far off set-url order followed by the far off name, and the distant's URL:
git remote set-url <remote-name> <remote-url>
The far off's URL can begin with HTTPS or SSH, contingent upon the convention you're utilizing. In the event that no convention is indicated, it defaults to SSH. The URL can be found on the storehouse page of your Git facilitating administration.
In case you're changing to HTTPS, the URL will look something like:
https://gitserver.com/user/repo_name.git
In case you're changing to SSH, the URL will resemble:
git@gitserver.com:user/repo_name.git
Also Read:- How to Build a Chrome Extension in JavaScript
For instance, to change the URL of the starting point to git@gitserver.com:user/repo_name.git you would type:
git remote set-url origin git@gitserver.com:user/repo_name.git
Confirm that the far off's URL was effectively changed by posting the distant associations:
git remote -v
The yield should resemble this:
origin ssh://git@gitserver.com:user/repo_name.git (fetch)
origin ssh://git@gitserver.com:user/repo_name.git (push)
That is it. You have effectively changed the URL of the far off.
Also Read:- How to Get User Posts from Faceboo Using PHP
What the git distant set-url order does is update the vault .git/config record with another URL to the far off store.
.git/config
...
[remote "origin"]
url = git@gitserver.com:user/repo_name.git
fetch = +refs/heads/*:refs/remotes/origin/*
You can likewise change the distant's URL by altering the .git/config document with a word processor . Notwithstanding, it is prescribed to utilize the git order.
Conclusion
Changing a Git far off's URL is as basic as running: git distant set-url <remote-name> <remote-url>.
In the event that you hit an issue or have input, leave a remark underneath.
Also Read:- Know More about The Various Types Of Technologies That Are Used In The Procedure Of Logistics Application Development
Also Read:- What are the best workouts for beginners in the home?