📅  最后修改于: 2023-12-03 15:15:16.507000             🧑  作者: Mango
As a programmer, it's common to work with Git repositories. One of the most common tasks is to update the origin URL of a repository. This can be done easily with Shell/Bash commands.
To change the origin URL of a Git repository, follow these steps:
Open the terminal or command prompt where the repository is located.
Type the following command:
git remote set-url origin <new_url>
Replace <new_url>
with the new URL for the repository.
Press Enter.
Verify that the new URL has been set by typing:
git remote -v
This will display the old and new URLs.
Let's say you have a repository named my_project
and the current origin URL is git@oldrepo.com:my_project.git
. You want to change the origin URL to https://newrepo.com/my_project.git
. Here's how you can do it:
cd my_project
git remote set-url origin https://newrepo.com/my_project.git
git remote -v
This will update the origin URL of the my_project
repository to https://newrepo.com/my_project.git
.
In this tutorial, we have learned how to change the origin URL of a Git repository using Shell/Bash commands. Updating the origin URL is a simple process and can be done in just a few steps.