jueves, 10 de noviembre de 2016

How to change URL of a remote git repository

A few days ago one of our developers quit his job and we assigned the laptop to another person. All the git repositories were configured with his account, so we had to change the url for every git repository.

The process to change the repository url is very simple.

To see what is the actual repository you have to use the command git remote -v, then you will see two lines showing you the fetch url and the push url. Something like the following lines:

origin  githost:USERNAME/REPOSITORY.git (fetch)
origin  githost:USERNAME/REPOSITORY.git (push)

To change the fetch url you have to execute the following command:
git remote set-url origin githost/USERNAME/OTHERREPOSITORY.git

And to change the push url the command is:
git remote set-url --push origin githost:USERNAME/OTHERREPOSITORY.git

That is it! You changed your urls.

No hay comentarios.:

Publicar un comentario