Question

For example, let we have a git repository A, which have two remotes:

user@user:~/dev/tmp/some_repo$ git remote -v
remote_a        /home/user/dev/tmp/a/ (fetch)
remote_a        /home/user/dev/tmp/a/ (push)
remote_b        /home/user/dev/tmp/b/ (fetch)
remote_b        /home/user/dev/tmp/b/ (push)

I want to clone this repository and get same remotes, but have only origin:

user@user:~/dev/tmp$ git clone some_repo/ some_clone
Cloning into 'some_clone'...
done.
user@user:~/dev/tmp$ cd some_clone/
user@user:~/dev/tmp/some_clone$ git remote -v
origin  /home/user/dev/tmp/some_repo/ (fetch)
origin  /home/user/dev/tmp/some_repo/ (push)

Is there any way to get all the remotes from the origin, so remote_a and remote_b were remotes for some_clone one too?

Was it helpful?

Solution

The protocols available to git (for cloning, fetching updates, and so on) do not give you the information required, so in one sense the answer is no: there is no way to get that.

For your specific example, though, the repository you're cloning is already local. You obviously have direct access to it. All you have to do is go over to it and use git config (or similar) to extract all the information needed, then copy it over to the new clone.

The same applies to a repository you clone from somewhere "far away": you need some other kind of access to it (such as the ability to ssh-log-in to the host machine) to get the configuration information you need.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top