Change a git repository’s remote

You can change the origin of a repo as follows:

git remote set-url origin [email protected]:root/securessh.git

Test it:

[email protected]:~/securessh# git remote set-url origin [email protected]:root/securessh.git
[email protected]:~/securessh# git push
The authenticity of host ' (' can't be established.
RSA key fingerprint is 97:1d:fa:f8:5f:42:6c:fb:f2:e8:17:a1:8e:99:cb:c5.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added ',' (RSA) to the list of known hosts.
Counting objects: 5, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 426 bytes, done.
Total 3 (delta 1), reused 3 (delta 1)
To [email protected]:root/securessh.git
   5446e24..0675043  master -> master

You are reading this post on Joel G Mathew’s tech blog. Joel's personal blog is the Eyrie, hosted here.