Skip to content

Update my forked repo

Mikael Roos edited this page Jan 15, 2020 · 2 revisions

Here is how you keep your forked repo up to date with the original course repo.

Precondition

You have installed the "Lab & Development Environment".

You know your way around "Working with Git and GitHub".

Use the terminal Git Bash, or similair.

Your setup

You forked the original course repo and you are now working on it as a local copy.

You have the tools to keep it updated, both localy and with its master on GitHub.

But how can you get updated when the original course repo is changed?

This is how you can trace changes made to the original course repo and update your own forked (and local) repo.

Sometimes git-people talk about upstream and downstream when they relate to the position of the repo.

Create another upstream for the original course repo

The original upstream for the course repo is available at the following url:

  • https://github.com/Webbprogrammering/websoft

Lets add that as another remote for our repo.

First check out the current remotes we have for our current upstream.

git remote -v

Then we add the new remote and label its origin as "source".

git remote add source https://github.com/Webbprogrammering/websoft

Lets check your remote again. You should now have two remotes, "origin" as you original upstream and now the added "source" upstream.

You can read about this in the help section for "Adding a remote" or in "Configuring a remote for a fork".

Get updates from the "source" upstream

You can fetch updates from the "source" upstream and its default master branch.

git pull source master

This will merge the "source" into your "origin". You may get merge issues if you have changed files in the "origin", that are available in the "source". That is why you always should do changes only to files below your work/ directory.

You can read more on this topic in "Syncing a fork".

Update your forked upstream

Once you merged with the latest "source" you need to update your forked version, your "origin" upstream. Do this with an ordinary push.

git push

Do a git status to see that all is okey.