Updating forks from original repo?

Hi, I have forked a project and wanted to keep my master branch up to date with the original repo. So I added the original repo as upstream using the terminal in the interactive environment of the fork, but then when I tried to run git pull upstream, I got fatal: unable to fork. Did I misunderstand something? Here is the terminal output:

 work ❯ et-data-copy ▶ testing ▶ ⬆ ▶ $ ▶ git remote add upstream git@renkulab.io:ba_math_gen-16/et-data.git
 work ❯ et-data-copy ▶ testing ▶ ⬆ ▶ $ ▶ git remote -v
origin  https://renkulab.io/gitlab/schymans/et-data-copy.git (fetch)
origin  https://renkulab.io/gitlab/schymans/et-data-copy.git (push)
upstream        git@renkulab.io:ba_math_gen-16/et-data.git (fetch)
upstream        git@renkulab.io:ba_math_gen-16/et-data.git (push)
 work ❯ et-data-copy ▶ testing ▶ ⬆ ▶ $ ▶ git checkout master
Switched to branch 'master'
Your branch is up to date with 'origin/master'.
 work ❯ et-data-copy ▶ master ▶ $ ▶ git pull upstream
fatal: unable to fork

Hi @schymans - you’ll want to add the https remote for upstream (you added the ssh remote) unless you want to handle ssh keys in your session. If the repo is private, you will have to generate a token (with read_repository scope) and use it like this:

git config credential.helper "store --file=.git/credentials"
echo "https://oauth2:<token>@renkulab.io" > .git/credentials

Be aware that if you script this somehow, having your token like this in your repo is potentially a security concern.

Hope that helps!

Thanks a lot for the quick reply! I tried again, but:

 work ❯ et-data-copy ▶ master ▶ $ ▶ git remote add upstream https://renkulab.io/gitlab/ba_math_gen-16/et-data.git
 work ❯ et-data-copy ▶ master ▶ $ ▶ git pull upstream
remote: HTTP Basic: Access denied
fatal: Authentication failed for 'https://renkulab.io/gitlab/ba_math_gen-16/et-data.git/'

The repo is “internal” and I cannot make it “public” for some reason, it is grayed out. Is this because I put it in the domain of a group?

Sorry I should have been more specific - “internal” requires authentication just like “private” - so you have to add the token in the way that I mentioned above.

I see, thanks! Is there a way that I could make it public?

Right, if it belongs to a group and the group is not public, the project cannot be public. You can change the visibility of the group first, if that’s an option?

Oh god, that was quite some mental block! Thank you!

1 Like

Ha! no worries. Hope you got it sorted :slight_smile: