I have a project I'm working on which will be deployed to heroku, however I would also like to keep a copy on github since that's my primary portfolio storage. It's simpler than you would think. Without further ado, let's get to it.
Here's what needs to happen to get multiple remote repositores.
- Create your local git file.
- Create your remote repositories.
- Create git path which pushes to both.
Creating a local git file is easy.
cd
into where you want your git file to live. Rungit init
to create an empty local git.For github here are instructions to create a new github repository. Once, your github repository has been created you can connect it to your project with
git remote add github your-github-repository-URL
. This will create a connection named github to your github repository located at your-github-repository-URL. Feel free to use a different name than github for your connection, but in this guide that will be the name I use for future commands.
For heroku, if you don't have an account you can read my guide on connecting a heroku account to a project here. Otherwise, if you do have a heroku account and heroku CLI, in the same directory as your .git folder in your terminal you can enterheroku create
to create a remote repository and link your project in one step.Now that you have two separate channels to push to, lets make a joint path. We'll create a new remote path named 'all' and initialize it with the github repository. You can choose either one as your primary, but I prefer github since it takes less time to upload to. So to add a path we do what we did before.
$ git remote add all your-github-repository-URL
$ git remote set-url --add --push all your-github-repository-URL
$ git remote set-url --add --push all your-heroku-git-repository-URL
You can verify it by entering git remote -v
which will print out the paths in git directory. Now all you have to do to push to both repositories is
$ git add .
$ git commit -m "make your change comments here"
$ git push all
Top comments (0)