What happens if the repo URL that we are using is suddenly changed and a new URL is provided.
If there are no uncommitted codes, we can simply clone the repo from the new location and continue our work.
But what if there is a lot of non-synced code in our local and we need to push those to the repo in the new URL?
** This is applicable if the existing repo is deleted and an exact copy of that repo is created in another location. We can use this solution in the case of Project Renaming also in azure.
We can fix this issue by changing the remote URL of the repo.
We can use the below commands through the git terminal
//To change the URL of a Git remote, you have to use the “git remote set-url” command and specify the name of the remote as well as the new remote URL to be changed $ git remote set-url <remote_name> <remote_url> //To verify the changes we made, you can use the “git remote” command with the “-v” option $ git remote -v //Example $ git remote set-url origin https://myrepo/new-path.git $ git remote -v
If you want to use the same remote name, first add a new remote with another name. Then remove the existing remote and rename the newly added remote to the needed name.
- Add a new repo with name origin1
- Remove the older repo named origin
- Edit and rename the new repo to origin
No comments:
Post a Comment