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! 👩💻
Top comments (1)
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!