I have a git repository living at git://server.local/repo.git
Cloning with git clone git://server.local/repot.git
sets up origin
like this:
$ 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 changing manually the remote URL).
Is that possible ?
Edit: I don't want to have to run any command or script after the cloning is done. I would like to configure the remotes URL on the server so that I don't have to manually change them after cloning a repository.
Looks like the gerrit solution is still the accepted one. Check out this answer to see how it can be done with a simple script.
Once the repository is cloned you can execute
git remote set-url origin git://server.local/repo.git
git remote set-url --push origin ssh://server.local/realrepopath/repo.git
Unfortunately, there doesn't seem to be a way to run scripts or hooks on a new git clone
(as far as I know).
The command
git config --global url."ssh://server.local/realrepopath/".pushInsteadOf git://server.local/
should do the trick.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.