I have fixed network of git remotes and I would like them to be attached to repository. Unfortunately git-clone doesn't clone remotes. Is there a way around it?
Asked
Active
Viewed 796 times
9
-
you found the way to solve this ?maybe make a script, and use a .gitremotes file similar to .gitmodules – JuanPablo Oct 08 '11 at 22:26
-
1Possible duplicate of [How to make git repo remember all remotes?](http://stackoverflow.com/questions/15286307/how-to-make-git-repo-remember-all-remotes) – sschuberth May 26 '16 at 12:10
4 Answers
5
I begin this command
https://github.com/juanpabloaj/git-remote-init
for save the remotes in a .gitremotes file

JuanPablo
- 23,792
- 39
- 118
- 164
-
nice script. I noticed that it assumes there are no remotes, and exits if there are any already defined. Do you typically bypass the default remote 'origin' that is set when you clone a repository? Otherwise this would of course exist after cloning and without doing anything special/non-standard, your script will return silently. Just curious about your workflow here. – timblaktu Oct 10 '20 at 20:23
2
There is no way to do this with git, as far as I know.
Telling users to run scripts post-clone is what people tend to do. If it's a ruby project, you probably have rake
, for example, so you could have a rake post_install
task.

August Lilleaas
- 54,010
- 13
- 102
- 111
-
-
hooks get created locally when the repository is initialized by whatever implementation of Git is used to clone the repository. – Jörg W Mittag Oct 15 '09 at 13:24
2
Remotes are saved in .git/config
file of a repo, you can extract your favorites and append them on every clone.

che
- 12,097
- 7
- 42
- 71
1
You could define them in your global config file ~/.gitconfig
instead of your project's .git/config
. Be careful though... if you run git remote update
in a project it will pull down all remotes, even for repositories completely unrelated to the one you're working on.

Pat Notz
- 208,672
- 30
- 90
- 92