首页 > 解决方案 > Git - 一个代码用于 2 个 repos,一个用于推送,另一个用于拉取

问题描述

我找到了一些使用 git 提供代码的框架。因此,他们的任何更新都可以被提取并合并到我自己的代码中。

但与此同时,我的代码链接到了我自己的远程存储库。

所以,问题是——如何——以及是否有可能将相同的代码链接到一个远程存储库以提取他们的更新,并链接到另一个存储库以将所有更新推送到那里?所以工作流程可能是:

  1. 创建我自己的本地仓库并从远程仓库#1 中提取代码。
  2. 在我的本地仓库中进行开发并将代码推送到我的远程仓库#2。
  3. 从 repo #1 中提取更新(如果有)。
  4. 转到第 2 步。

如何?可能的?

标签: git

解决方案


You can add an additional remote repo with git remote add <repo-name> <url> -- just pick a unique name for the remote (not the same as the one you're pulling from!) and its URL.

Then, you can use git push <repo-name> to push your current branch to the same named branch in that remote repo. You can use git branch -u <repo-name> <branch> to set the default upstream of branch to be repo-name -- then you can use simply git push to push to it (but you'll then need to use git pull <orig-repo> to pull more changes from the original repo.)


推荐阅读