Friday, 26 March 2021

Changing Git Remote Urls

I recently switched network settings, and now my IPs have changed, and my remotes no longer match.

A quick google1 for the right syntax is all I needed.

mrbear@labtop mygitrepository % git remote -v
origin ssh://mrbear@10.0.0.1:/home/mrbear/mygitrepository (fetch)
origin ssh://mrbear@10.0.0.1:/home/mrbear/mygitrepository (push)

So my setup changed ips from 10.0.0.0 network to 192.168.2.0 network.

% git remote set-url origin ssh://mrbear@192.168.2.1:/home/mrbear/mygitrepository
mrbear@labtop mygitrepository % git remote -v
origin ssh://mrbear@192.168.2.1:/home/mrbear/mygitrepository (fetch)
origin ssh://mrbear@192.168.2.1:/home/mrbear/mygitrepository (push)

Verification is always a good thing.

% git pull
mrbear@192.168.2.1's password:
remote: Enumerating objects: 19, done.
remote: Counting objects: 100% (19/19), done.
remote: Compressing objects: 100% (16/16), done.
remote: Total 16 (delta 8), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (16/16), 93.48 KiB | 3.89 MiB/s, done.
From ssh://192.168.2.1:/home/mrbear/mygitrepository
7f41ba8..e7de4cf master -> origin/master
Updating 7f41ba8..e7de4cf
Fast-forward

References

[1] Managing remote repositories
https://docs.github.com/en/github/getting-started-with-github/managing-remote-repositories

No comments:

Post a Comment