HelloCW
HelloCW

Reputation: 2255

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?

Upvotes: 2

Views: 1623

Answers (2)

Anjali Vashishtha
Anjali Vashishtha

Reputation: 11

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.

Upvotes: 1

a1300
a1300

Reputation: 2813

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 [email protected]: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

Upvotes: 3

Related Questions