Change git remote url updates but don't click

I am trying to change the remote URL of my origin branch in Git. All I want to change is the SSH port. Firstly, listing my remote source gives me the following:

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 source URL:

 git remote set-url origin ssh:// user@example.com :XX/package/name.git (XX is my port #) 

Now I can get it without problems, but redirecting my branch to the beginning does not work because the push url has not changed. Listing my remotes again, I get the following:

 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 extraction set-url ?

+5
source share
1 answer

From the 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 must additionally perform:

  git remote set-url --push origin ssh:// user@example.com :XX/package/name.git 
+8
source

Source: https://habr.com/ru/post/1263396/


All Articles