我在一个好地方找到了一个Github开源项目与他人分享(我们称之为Repo A)。我想将代码复制到名为Repo B的新回购(白色标签)中。
小结
我需要以下建议:
如何在Repo B上设置遥控器,以便在Repo B上引入新功能时,我可以让它更新Repo A?我愿意通过持续集成来做到这一点。
答案 0 :(得分:0)
使用git,拥有多个遥控器就像推动它们一样简单!
在GitHub上创建存储库后,请您将“origin”远程添加到本地存储库。 (回购A )
git remote add origin git@github.com/user/repo.git
您可以根据需要创建任意数量的遥控器! synthax总是一样的:
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 :
**简短回顾**
完成此基本设置后,您可以重复此操作: