Keeping Your Fork Up-to-date
Amanda Giannelli
Posted on March 31, 2021
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
Clone your fork
$ git clone git@github.com:[user]/[repo].git
Add the upstream
$ git remote add upstream git://github.com/[user]/[repo].git
Get the latest upstream
$ git fetch upstream
Bring your fork up to date using
merge
ORrebase
(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! 👩💻
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
September 20, 2024