简体   繁体   中英

How to fork a project in Github again?

I forked the project https://github.com/android/camera-samples a month ago, the forked project is listed as myname/camera in my repo.

Today I find that https://github.com/android/camera-samples has been updated, I fork the project again.

In my mind, the old myname/camera in my repo will be update, but in fact no action im my myname/camera.

Do I must delete myname/camera in my repo first, then fork https://github.com/android/camera-samples for the latest edition?

You need to sync your fork. The best thing would be to familiarize yourself with the concept of remotes

See all of your remotes via command line:

git remote -v

Before your update (your remotes look like this)

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

After your update (your remote changed)

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)

You need to add a remote and pull from the upstream repository and push the updates to your fork.

upstream  -->  local clone --> your fork


Follow these steps:

1. Clone your fork (to your local machine):

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

2. Add remote from original repository (upstream) in your forked repository:

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

3. Updating your fork from original repo to keep up with their changes:

git pull upstream master

Source: https://gist.github.com/CristinaSolana/1885435

Github page snapshot showing how to fetch updated code

No need to delete the forked repo and fork again.

Did you notice the pop-up stating fetch upstream on your forked-repo?

Click that button, then see the dropdown to fetch and merge

Click that and the updated-forked-repo becomes available without deleting the original forked repo .

Have a look at the image and it might help you find the option.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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