Changing Git remote URL updates fetch but not push

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?

  • Git receive.denyCurrentBranch updateInstead fails
  • Openshift: how to install python modules from private repository?
  • Kali linux “could not resolve host github.com” error
  • Heroku Deployment from multiple win7 64 machines
  • Can't access AWS CodeCommit with SSH
  • How to deploy new code via git, if git only installed on my user?
  • How to git clone via ssh without having to type in a password?
  • permission denied (public key) error for ssh -vT git@heroku.com
  • One Solution collect form web for “Changing Git remote URL updates fetch but not push”

    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
    
    Git Baby is a git and github fan, let's start git clone.