繁体   English   中英

如何再次在 Github 中分叉一个项目?

[英]How to fork a project in Github again?

一个月前,我分叉了项目https://github.com/android/camera-samples ,分叉的项目在我的仓库中列为 myname/camera。

今天发现https://github.com/android/camera-samples已经更新了,我又fork了这个项目。

在我看来,我的 repo 中的旧 myname/camera 将被更新,但实际上我的 myname/camera 没有任何动作。

我是否必须先在我的仓库中删除 myname/camera,然后 fork https://github.com/android/camera-samples以获得最新版本?

您需要sync您的分叉。 最好的办法是熟悉遥控器的概念

通过命令行查看所有remotes

git remote -v

更新之前(您的遥控器看起来像这样)

git remote -v
origin  https://github.com/HelloCW/camera-samples (fetch)
origin  https://github.com/HelloCW/camera-samples (push)

更新后(您的遥控器已更改)

git remote -v
origin  https://github.com/HelloCW/camera-samples (fetch)
origin  https://github.com/HelloCW/camera-samples (push)
upstream        https://github.com/android/camera-samples (fetch)
upstream        https://github.com/android/camera-samples (push)

您需要add远程并从上游存储库中pull并将更新推送到您的 fork。

upstream  -->  local clone --> your fork


按着这些次序:

1. 克隆你的 fork(到你的本地机器):

git clone git@github.com:YOUR-USERNAME/YOUR-FORKED-REPO.git

2. 在您的分叉存储库中添加来自原始存储库(上游)的远程:

cd into/cloned/fork-repo
git remote add upstream git://github.com/ORIGINAL-DEV-USERNAME/REPO-YOU-FORKED-FROM.git
git fetch upstream

3. 从原始 repo 更新你的 fork 以跟上他们的变化:

git pull upstream master

资料来源: https://gist.github.com/CristinaSolana/1885435

Github 页面快照显示如何获取更新的代码

无需删除分叉的回购并再次分叉。

您是否注意到在您的分叉存储库中显示fetch upstream的弹出窗口?

单击该按钮,然后查看下拉菜单以fetch and merge

单击按钮, updated-forked-repo变为可用,而不会删除original forked repo

查看图像,它可能会帮助您找到选项。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM