When I create a new project in my gitlab, I get a default name origin
for the repository in the server.
Then I may use git remote add [name] [url]
to create several so-called remote repositories. If I type git remote
, I just get something followed:
$ git remote
name1
name2
origin
Actually I can only see one repository namely the project in my gitlab, where are the others? So after I use git push name1
, does it push
to all of the remote repositories or just push
to the origin
? I don't see any difference compared to the way without adding names.
git remote add [name] [url]
adds the name
as an alias for the url
in the current local repository. The alias is named "a remote" (noun). No distant (I have to use the word "distant" to avoid using "remote") server is contacted, even less no distant repositories are created.
after I use
git push name1
, does it push to all of the remote repositories or just push to theorigin
?
The syntax is
git push [remote [ref]]
That is, you can do git push
(will push the default refs to the default remote; depends on configuration, but usually it pushes the current branch to its upstream remote, usually origin
); or you can do git push name1
naming the remote explicitly; or you can do git push name1 master
naming the remote and the branch.
There is no builtin way to push to multiple remotes but it's possible with additional command line tools.