DEV Community

Cover image for Keeping Your Fork Up-to-date
Amanda Giannelli
Amanda Giannelli

Posted on

Keeping Your Fork Up-to-date

When you fork a repository, you are creating your own copy to manage. Development will continue on the main repository so your fork may fall behind.

Today's quick lesson:

Keeping your forked repository up to date with the main repository

Steps

  1. Clone your fork
    $ git clone git@github.com:[user]/[repo].git

  2. Add the upstream
    $ git remote add upstream git://github.com/[user]/[repo].git

  3. Get the latest upstream
    $ git fetch upstream

  4. Bring your fork up to date using merge OR rebase
    (pick one, you can read more about the differences here)
    $ git merge upstream/[remote-branch] [local-branch]
    -OR-
    $ git rebase upstream/[remote-branch] [local-branch]

Done! šŸŽ‰ Your local fork is now up to date. For future updates, you will only need steps 3 and 4 as you have already established the upstream.

I hoped this helped you. If there are other quick tips you'd like, or more in depth topics you'd like me to cover, leave a comment or reach out to me, @giannelli.tech

Thanks for reading! šŸ‘©ā€šŸ’»

Photo by Yancy Min on Unsplash

Top comments (1)

Collapse
 
ajcwebdev profile image
ajcwebdev

Not gonna lie, when I want to make a PR for something I forked awhile ago I usually just blow it away and re-fork, so this is actually really useful for me to know! Thanks!