YouTube Icon

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.

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

Our mission is "Har Koi Dekhe Video, Har Ghar Dekhe Video, Ghar Ghar Dekhe Video" so we Provide videos related to Tutorials, Travel, Technology, Wedding, Cooking, Dance, Festivals, Celebration.

Apna Video Wala
CFT

News & Blogs

26e9f80f246a23959e6dd1e9d44d9e80.jpg

Top 5 Trends in Software Development

2023 will see significant changes in the corporate environment as a result of unprecedentedly hig...

94d5386f13221e699ddc5bc772b77466.jpg

Gusto Payroll App, Should You Clone It?

When it comes to payroll management, there are only a few platforms as popular as Gusto Payroll a...

668170c13e4a1503c5840296c1b49277.jpg

Top Factors to Consider While Selecting an Idea...

In today's rapidly evolving digital landscape, cloud computing has become an essential compon...

Top Authors

Lamia Rochdi is the Marketing Manager at Bell Flavors & Fragrances EMEA. A successful family-...

Lamia Rochdi

I’m Mertin Wilson a technician in a camera company and certified expert of different P...

Mertin Wilson

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

Zakariya Usman

Pankaj Singh is a Senior Digital Marketing Consultant with more than 2 years of experience in SEO...

Pankaj Singh
CFT

Our Client Says

WhatsApp Chat with Our Support Team