How to Change the URL of a Git Repository
Git is one of the most popular version control systems for software development. It allows developers to collaborate on projects, track changes, and revert back to previous versions of the codebase. However, there may be times when you need to change the URL of your Git repository. Whether it's because you're moving the repository to a different server, or because you're changing the hosting provider, you can follow these steps to update your local copy of the repository.
- Copy the new repository URL to your clipboard.
- In your terminal, navigate to the directory where you have a local copy of the existing repository.
-
Run the following command to remove the current origin remote:
$ git remote remove origin -
Now, add the new origin remote using the following command:
$ git remote add origin <new-repository-url> -
Download the latest changes using the following command:
$ git fetch origin -
Next, switch your development branch to the main branch:
$ git checkout master -
Now merge your local master branch with the new origin/master:
$ git reset --hard origin/master -
Finally, push your changes to the new repository:
$ git push -u origin master
This procedure should be performed for each development branch that you have in your local copy. After that, you should be able to continue working with the new repository.
No comments:
Post a Comment