Is there a way to add multiple git repositories in the same Google cloud project?
6 Answers
You currently cannot do this. We know this is a useful feature, and we're working hard on it. Stay tuned!

- 13,313
- 16
- 79
- 92

- 74
- 1
- 2
We've added the ability to have multiple Cloud Source Repositories for every cloud project.
You can read about how to add a new repo to your project here: https://cloud.google.com/source-repositories/docs/setting-up-repositories

- 2,453
- 1
- 20
- 18
There is no way of doing this as of today. Every project can only have one remote
repository.

- 2,405
- 1
- 20
- 24
Every Google cloud project can only have one remote repository.
However, t's definitely possible to have multiple local repositories that correspond with the same remote Google cloud repository.
The official documentation describes the following procedure for how to use a Cloud Source Repository as a remote for a local Git repository :
Create a local Git repository
Now, create a repository in your environment using the Git command line tool and pull the source files for a sample application into the repository. If you have real-world application files, you can use these instead.
$ cd $HOME $ git init my-project $ cd my-project $ git pull https://github.com/GoogleCloudPlatform/appengine-helloworld-python
Add the Cloud Source Repository as a remote
Authenticate with Google Cloud Platform and add the Cloud Source Repository as a Git remote.
On Linux or Mac OS X:
$ gcloud auth login $ git config credential.helper gcloud.sh $ git remote add google https://source.developers.google.com/p/<project-id>/
On Windows:
$ gcloud auth login $ git config credential.helper gcloud.cmd $ git remote add google https://source.developers.google.com/p/<project-id>/
The credential helper scripts provide the information needed by Git to connect securely to the Cloud Source Repository using your Google account credentials. You don't need to perform any additional configuration steps (for example, uploading ssh keys) to establish this secure connection.
Note that the
gcloud
command must be in your$PATH
for the credential helper scripts to work.
It also explains how to create a local git by cloning a Cloud Source repository :
Clone a Cloud Source Repository
Alternatively, you can create a new local Git repository by cloning the contents of an existing Cloud Source Repository:
$ gcloud init $ gcloud source repos clone default <local-directory> $ cd <local-directory>
The
gcloud source repos clone
command adds the Cloud Source Repository as a remote namedorigin
and clones it into a local Git repository located in<local-directory>
.

- 45,213
- 22
- 199
- 169
-
Yes but the question is can you have multiple remote repos inside of a project. So something like `/p/
/ – Chad Cache Mar 24 '16 at 20:26`
No, there isn't, but you can use Git subtree merges
to add multiple "subrepositories" as folders in your main repository, which will do the trick.
See details here https://help.github.com/articles/about-git-subtree-merges/
(There are also submodules
as @Shishir stated, but as I understand they are only set for your current local clone and won't be included in checkouts/clones done by others, so I think submodules won't work).

- 2,672
- 13
- 18
-
git clone --recursive https://github.com/chaconinc/MainProject would get submodules. There are other ways also, but i find this to be the easiest. – Shishir Mar 31 '16 at 02:32