Git

Git – Add a forked repo branch to the upstream repo

If you have a forked repo and need to do a merge request/ pull request to the upstream repo but you don’t have permissions to run the MR/PR pipelines and don’t have any pipelines in the forked repo. Then the solution is to bring the forked repo into the upstream repo as a branch and then do a MR/PR. Do this:-

Context:-

We have a repo called “AwesomeHelloWorld” which has agents/runners to run the pipelines. A user called “User101” forks this repo to “User101/AwesomeHelloWorld” they then create a MR/PR but this cannot run as there are no agents/runners to run the pipeline in “User101/AwesomeHelloWorld“.

They cannot use the upstream “AwesomeHelloWorld” as they do not have permission.

To get the MR/PR to work, you can bring the branch from the “User101/AwesomeHelloWorld" into the “AwesomeHelloWorld” repo and then you will have permission to run the MR/PR using the agents/runners.

User101 creates a new branch in their forked repo called “New_feature

Add the remote forked repo (User101/AwesomeHelloWorld) to your git (AwesomeHelloWorld)

git remote add User101/AwesomeHelloWorld [email protected]:User101/AwesomeHelloWorld.git

Check out the new branch locally

git checkout New_feature

Then push the new local branch to the remote branch of your upstream repo (AwesomeHelloWorld)

git push origin New_feature

Your branch is now in your remote origin (AwesomeHelloWorld). Now just do a MR/PR as normal.