簡體   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