THE BEST NEWSLETTER ANYWHERE
Join 6,000 subscribers and get a daily digest of full stack tutorials delivered to your inbox directly.No spam ever. Unsubscribe any time.
This tutorial explains how to change the remote repository for an existing local repository
This will be used once you migrated the repository from different repositories such as GitHub, GitLab, and bitbucket.
Following are the steps required to change the GitHub remote repository.
One way using the command line
First, run the git remote -v command on an existing repository
B:\myproject>git remote -v
origin <https://github.com/user/gitrepo.git> (fetch)
origin <https://github.com/user/gitrepo.git> (push)
It points to the GitHub remote repository
origin is a remote repository
B:\myproject>git remote set-url origin https://gitlab.com/user/gitlabrepo.git
B:\mygitrepo>git remote -v
origin <https://gitlab.com/user/gitlabrepo.git> (fetch)
origin <https://gitlab.com/user/gitlabrepo.git> (push)
Another way using .git/config folder
.git/config
in a text editor [remote "origin"]
url = https://github.com/user/gitrepo.git
Change url to the new remote repository
[remote "origin"]
url = https://gitlab.com/user/mygitrepo.git
To change the local repository from GitLab to GitHub
git remote -v
command in the Local repositorygit remote set-url origin newurl
commandThis is a similar way to change local repository from GitHub to GitLab
🧮 Tags
Recent posts
Puppeteer Login Test example How to convert Double to Integer or Integer to double in Dart| Flutter By Example Best ways to fix 504 gateway time out in nodejs Applications Fix for Error No configuration provided for scss Multiple ways to List containers in a Docker with examplesRelated posts