DEV Community

Eka
Eka

Posted on

3

Pull (fetch) from a forked GitHub repository

You are working on a project outside of your or your organisation account--an open source project for Hacktoberfest, perhaps. You forked the repo and started working on it.

Meanwhile, the original repo has been updated with new changes. To prevent conflict, you need to pull these changes from the original repo and merge it to your local, forked branch. But wait... how do you do that? β“πŸ€”

Follow these steps and you'll be good to go. 😎

(1) add remote

git remote add upstream https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git

(2) fetch

git fetch upstream

Commits to the remote main branch will be stored in a local branch called upstream/main (same with other branches).

(3) merge to local, then merge to your working branch (if necessary)

git checkout main
git merge upstream/main

# merge to working branch
git checkout eka/working-branch
git merge main

Done!

References

Sentry image

See why 4M developers consider Sentry, β€œnot bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

πŸ‘‹ Kindness is contagious

Please leave a ❀️ or a friendly comment on this post if you found it helpful!

Okay