Refreshing a Fork

I have forked a repository that is constantly updated by the creator. How do I go about updating my forked copy so that I have the most up-to-date files?


you can do that in two ways. Both of them expect that you never work on the default branch (main/master, check your project settings) of your fork, but only create change commits in feature and fix branches.

GitLab Repository Mirror

Navigate into Settings > Repository > Mirroring repositories.

  • Add the upstream URL
  • Mirror direction: Pull
  • Tick Only mirror protected branches (optional)

I’m doing that for since I don’t have edit rights, but always want to fix typos in the Web IDE on the most recent state.


Add a secondary remote called upstream.

git remote add upstream https://...

Fetch the remote and then pull its changes into your local master branch.

git checkout master
git fetch upstream
git pull upstream master

Last, push to your own remote origin to keep the forked repo in sync.

git push origin master

Based on the master branch, you can continue with creating branches, e.g. git checkout -b feature/....

You could also write a script for that, e.g. when you’re syncing between different Git servers.



Thank you for that detailed instruction. With your first option (GitLab Repository Mirror), I only have the option for PUSH for Mirror Direction. Any idea why this might be?


maybe the form needs a refresh, I’ve found it a bit wonky when adding a new item. Or the URL you’re providing above is the same as the current repository. Can you share a screenshot?


Hi - Please see the attached screenshot.

Look valid to me. Maybe try hitting refresh once, then copy the URL again. I had some issues with the different form states until it allowed me to change the mirror direction. Though I was using, not sure whether this is an advanced option only applicable in EE.


Seems the issue is that I’m on a hosted GitLab through my company. When I try this on, I have the Push/Pull option, but when I’m on my company’s site, I only have Pull.

Ah, I see. Didn’t look into the specific docs section where this feature is marked as a paid tier feature.

In that case (assuming you’re using the free tier), I’d suggest going the manual scripted way with adding that to a cronjob somewhere. Or you’ll migrate to Premium/Ultimate :slight_smile:


worked liked a charm :grinning: :grinning:

1 Like

Thank you, you saved my day! :)))

1 Like