Marian Paździoch
Marian Paździoch

Reputation: 9103

Clone repository from other user but push to / pull from main server

Few users use main server with repository and clone it by:

git clone --recursive git@gitsrv:Android/sw/Android.git

It last very long (more than a day).

So I've read that I can clone directly from other user if he has already cloned repo from server by: How can I 'git clone' from another machine?

But I mustn't push into other user repo. I must push to main server. And further pulls must be also done from server not from other user. How to do that?

And by the way: where "gitsrv" is defined (it's a kind of symlink?) ?

Upvotes: 2

Views: 161

Answers (1)

First Zero
First Zero

Reputation: 22356

This can be done easily by running git daemon on the user machine - assuming it is called machineA. Example - git daemon --base-path=<absolute full path to git repo>

To clone from that machine - git clone git://machineA/foo.git.

For pushing to a different machine, add in a remote server - git remote add main ssh://mainServer/foo.git and then push using git push -u main master

Remove reference to machineA by git remote remove origin. Assuming that your remote server is named origin. If you are not sure of the name you can check by running git remote -v, that will list the reference name and the URL.

If you want to keep the name origin, just set the url by running git remote set-url origin ssh://mainServer/foo.git

Upvotes: 1

Related Questions