Breno Martinusso

~/archive/tech/How to upgrade a fork with changes from the original?

How to upgrade a fork with changes from the original?

Specify a new remote upstream repository that will be synced with the fork.

git remote add upstream [email protected]:ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git

Verify the new upstream repository you’ve specified for your fork.

git remote -v
# origin    [email protected]:YOUR_USERNAME/YOUR_FORK.git (fetch)
# origin    [email protected]:YOUR_USERNAME/YOUR_FORK.git (push)
# upstream  [email protected]:ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git (fetch)
# upstream  [email protected]:ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git (push)

Fetch all the branches from the upstream repository.

git fetch upstream

Check out the master branch from your local fork.

git checkout master

Now merge the changes from upstream/master into your local master branch.

git merge upstream/master

posted on