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 master branch of your fork, but only create change commits in feature and fix branches.
GitLab Repository Mirror
Settings > Repository > Mirroring repositories.
- Add the upstream URL
- Mirror direction:
Only mirror protected branches(optional)
I’m doing that for gitlab.com 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
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?
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 gitlab.com, 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 gitlab.com, 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
In that case (assuming you’re using CE), I’d suggest going the manual scripted way with adding that to a cronjob somewhere. Or you’ll migrate to EE