DEV Community

Cover image for ➕ GIT: ⏬ Pulling from a different repository.
The Black Mamba🔥
The Black Mamba🔥

Posted on

➕ GIT: ⏬ Pulling from a different repository.

Recently while working on a freelance project, i came across an interesting scenario where the previous developer has maintained 2 repositories, one in gitlab and the other in heroku.

The gitlab account is a repository to hold the code, and the heroku repository is linked to the build pipeline. i have made changes to the gitlab repository and the changes needs to be made to the master branch of heroku repository.

This is a scenario which i have never encountered before. After some investigation i found out that, you would do this when you want to create a new app from the same base or core (that's meant to be its purpose, but the scenario here is different).

Coming to the solution,

  • Add the other repository as a remote
    git remote add upstream https://www.gitlab.com/something/somrepo.git
    (upstream refers to the gitlab repository)

  • Now the two remotes will be shown (Screenshot from Source Tree)
    Sourcetree

  • Now pull the changes from master branch of gitlab repository to heroku.
    git pull upstream master

  • Push the changes to the repository , now your heroku branch will have all the changes from the master branch of gitlab.

Twitter Follow

Top comments (5)

Collapse
 
deta19 profile image
mihai

sooo, can't you just ... use the heroku command to get the changes? to update?

Collapse
 
blackmamba profile image
The Black Mamba🔥

which heroku command? I don't have much experience in heroku

Collapse
 
therealkevinard profile image
Kevin Ard

Even better - considering this is gitlab - why does it not use gitlab-ci to trigger builds?

Collapse
 
blackmamba profile image
The Black Mamba🔥

It's the first thing that i checked ,there was no ci setup and to create a runner you have to access the project settings, which can only be done by maintainer or admin and my role is developer.

Thread Thread
 
therealkevinard profile image
Kevin Ard • Edited

Probably worthless here, but since we're talking about multiple remotes: you could totally add a third remote for your fork, which has gl-ci running on it for pushing to heroku. (Worthless, unless you intend to a) setup the project more correctly or b) out-fancy the other party in front of the client. Your call lol)