How to set up a repo so that when cloning it has two different addresses for pushing and fetching?

I have a git repository living in git: //server.local/repo.git

Cloning with git clone git://server.local/repot.gitinstalls originas follows:

$ git remote -v
origin  git://server.local/repo.git (fetch)
origin  git://server.local/repo.git (push)

But I would like this instead:

$ git remote -v
origin  git://server.local/repo.git (fetch)
origin  ssh://server.local/realrepopath/repo.git (push)

I want this to be done automatically when cloning (without manually changing the remote URL).

Is it possible?

Edit: I do not want to run any command or script after cloning is complete. I would like to configure the URL of the remote servers on the server so that I don't have to manually change them after cloning the repository.

+3
source share
3 answers

, gerrit - . , , script.

0

git remote set-url origin git://server.local/repo.git
git remote set-url --push origin ssh://server.local/realrepopath/repo.git

, , git clone ( ).

0

Team

git config --global url."ssh://server.local/realrepopath/".pushInsteadOf git://server.local/

gotta do the trick.

0
source

All Articles