Keeping Your Fork Up-to-date

giannellitech

Amanda Giannelli

Posted on March 31, 2021

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

💖 💪 🙅 🚩
giannellitech
Amanda Giannelli

Posted on March 31, 2021

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related