Github Strategy/Remote 开源项目设置

Github Strategy/Remote Setup for Open Source Project

我在一个与他人共享的好地方获得了一个 Github 开源项目(我们称之为 Repo A)。我想将代码复制到一个名为 Repo B 的新回购(白色标签)中。

回顾

我需要以下方面的建议:

如何在 Repo B 上设置遥控器,以便在 Repo B 上引入新功能时,我可以让它更新 Repo A?我愿意通过持续集成来做到这一点。

使用 git,拥有多个遥控器就像推送它们一样简单!

在 GitHub 创建存储库后,请您将 "origin" 远程添加到本地存储库。 (回购 A)

git remote add origin git@github.com/user/repo.git

您可以创建任意数量的遥控器!语法始终相同:

git remote add NAME URL

(有关详细信息,请参阅 The git-remote man page

Repo B添加为另一个远程后,您可以将主分支从Repo A推送到Repo B .

请确保您已获取最新代码!

# On the master branch
git checkout master

# Get the latest code
git fetch

# Merge the code from master at repoB
# to your local master branch
git merge repoB/master

# Push the local master branch to RepoA
git push origin master

这应该完全符合您的期望。确保也推送其他分支和标签!

(推送时可能会使用--mirror选项)

更新 1:

**简短回顾**

  1. 从 GitHub
  2. 克隆 repoA
  3. 如果尚未创建,请创建 repoB。 (本地或在线,例如 GitHub)
  4. 使用 Repo 的 URL 设置 RepoB 远程。

完成此基本设置后,您可以重复此操作:

  1. 从 RepoB 中提取所有内容
  2. 将你喜欢的一切推送到 RepoA