A lot of time I have seen people asking how to handle two git repo from the same directory. It seems pretty simple as most of them have pushed much application on Heroku. So on regular basis, they keep pushing code to GitHub or Bitbucket and once everything is tested out, they push their code on Heroku. Which is exactly what they are asking.
Ok, enough with the stories, it’s all about setting a new different origin. Let me explain this via Heroku example. When you are using Github, to push the code on master branch you do it via
Now to push it on Heroku, you do
Here you are doing the same, pushing the code to different repositories where things are different from two origin points ie Heroku and origin :). So let’s assume we have two repositories ie repository_1 and repository_2 with remote URLs email@example.com:mohitjain/repository_1.git and firstname.lastname@example.org:mohitjain/repository_2.git respectively.Now setup two different origins in your local git repository
Now you can push on repository_1 by:
and in another repository_2 by:
Similarly, you can pull from different repositories. Or create aliases something like this (Be careful while doing this):