Changing Git remote URL updates fetch but not push
git, ssh
Solution
From `git-remote` manual:
set-url
Changes URL remote points to. Sets first URL remote points to matching regex <oldurl> (first URL if no <oldurl> is given) to <newurl>. If <oldurl> doesn’t match any URL,
error occurs and nothing is changed.
With --push, push URLs are manipulated instead of fetch URLs.
So you should additionally execute:
git remote set-url --push origin ssh://user@example.com:XX/package/name.git
Problem
I am attempting to change the remote URL of my origin branch in Git. All I want to change is the SSH port. First, listing my remote origins gives me this: ``` git remote -v origin user@example.com:package/name.git (fetch) origin user@example.com:package/name.git (push) ``` Then, I run the `set-url` command to change my origin URL: ``` git remote set-url origin ssh://user@example.com:XX/package/name.git (XX is my port #) ``` Now, I can fetch without issue, but pushing my branch to origin doesn't work, because the push URL didn't change. Listing my remotes again I get this: ``` git remote -v origin ssh://user@example.com:XX/package/name.git (fetch) origin user@example.com:package/name.git (push) ``` Why did my `set-url` command only change the fetch URL?