How to Change a Git Remote's URL




How to Change a Git Remote's URL

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?



Author Biography.

Lokesh Gupta
Lokesh Gupta

Overall 3+ years of experience as a Full Stack Developer with a demonstrated history of working in the information technology and services industry. I enjoy solving complex problems within budget and deadlines putting my skills on PHP, MySQL, Python, Codeigniter, Yii2, Laravel, AngularJS, ReactJS, NodeJS to best use. Through Knowledge of UML & visual modeling, application architecture design & business process modeling. Successfully delivered various projects, based on different technologies across the globe.

Join Our Newsletter.

Subscribe to CrowdforThink newsletter to get daily update directly deliver into your inbox.

CrowdforJobs is an advanced hiring platform based on artificial intelligence, enabling recruiters to hire top talent effortlessly.

CrowdforJobs

CrowdforApps brings to you the well researched list of the most successful and finest App development companies, Web software developers.

CrowdforApps

CrowdforGeeks is where lifelong learners come to learn the skills they need, to land the jobs they want, to build the lives they deserve.

CrowdforGeeks

CrowdforThink is a leading Indian media and information platform, known for its end-to-end coverage of the Indian startup ecosystem.

CrowdforThink
CFT

News & Blogs

6466cad5f49c2ac3321ab265d6b57cd3.jpg

Best Funny WhatsApp Stickers App of 2020.

WhatsApp App launches its new feature of sending stickers to your friend and family. There a...

e6aa2939636839489176a9c3a2127e77.png

How to Install Google Chrome Web Browser on Deb...

Google Chrome is the most mainstream internet browser on the planet. It is quick, natural, and se...

1f766b172fcbda319e2081df18bafeac.png

Which is best animation software for beginners?

Animation can be brutal. If the lengthy hours of strict attention don’t get to you, then th...

Top Authors

Hey, I am Suraj - a full-time blogger and a social media expert currently working on the Growth H...

Suraj Kumar

Zakariya has recently joined the PakWheels team as a Content Marketing Executive, shortly after g...

Zakariya Usman

Overall 3+ years of experience as a Full Stack Developer with a demonstrated history of working i...

Lokesh Gupta

With good communication and writing skiils, Astha Sharma is a full-time content writer working wi...

Astha Sharma
CFT

Our Client Says

WhatsApp Chat with Our Support Team