在同一 Google 云项目中添加多个 git 存储库的可能方法
Possible way to add multiple git repositories in the same Google cloud project
有没有办法在同一个 Google 云项目中添加多个 git 存储库?
每个 Google 云项目只能有一个 远程 存储库。
但是,绝对有可能有多个 local 存储库对应于相同的 remote Google 云存储库。
The official documentation 描述了如何将云源存储库用作本地 Git 存储库的远程程序的以下过程:
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.
它 also explains 如何通过克隆 Cloud Source 存储库创建本地 git :
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 named origin
and clones it into a local Git
repository located in <local-directory>
.
到今天为止还没有办法做到这一点。每个项目只能有一个 remote
个存储库。
Git 子模块应该可以解决问题。添加 git 个存储库作为子模块。
见
您目前无法执行此操作。我们知道这是一个有用的功能,我们正在为此努力。敬请期待!
不,没有,但是您可以使用 Git subtree merges
在您的主存储库中添加多个 "subrepositories" 作为文件夹,这样就可以了。
在此处查看详细信息https://help.github.com/articles/about-git-subtree-merges/
(正如@Shishir 所说,还有 submodules
,但据我了解,它们仅针对您当前的本地克隆设置,不会包含在其他人完成的 checkouts/clones 中,所以我认为子模块不起作用)。
我们添加了为每个云项目拥有多个云源存储库的功能。
您可以在此处阅读有关如何向您的项目添加新存储库的信息:https://cloud.google.com/source-repositories/docs/setting-up-repositories
有没有办法在同一个 Google 云项目中添加多个 git 存储库?
每个 Google 云项目只能有一个 远程 存储库。
但是,绝对有可能有多个 local 存储库对应于相同的 remote Google 云存储库。
The official documentation 描述了如何将云源存储库用作本地 Git 存储库的远程程序的以下过程:
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.
它 also explains 如何通过克隆 Cloud Source 存储库创建本地 git :
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>
.
到今天为止还没有办法做到这一点。每个项目只能有一个 remote
个存储库。
Git 子模块应该可以解决问题。添加 git 个存储库作为子模块。
见
您目前无法执行此操作。我们知道这是一个有用的功能,我们正在为此努力。敬请期待!
不,没有,但是您可以使用 Git subtree merges
在您的主存储库中添加多个 "subrepositories" 作为文件夹,这样就可以了。
在此处查看详细信息https://help.github.com/articles/about-git-subtree-merges/
(正如@Shishir 所说,还有 submodules
,但据我了解,它们仅针对您当前的本地克隆设置,不会包含在其他人完成的 checkouts/clones 中,所以我认为子模块不起作用)。
我们添加了为每个云项目拥有多个云源存储库的功能。
您可以在此处阅读有关如何向您的项目添加新存储库的信息:https://cloud.google.com/source-repositories/docs/setting-up-repositories