Reputation: 21025
I have a repository on bitbucket. I push to it by doing:
git push -u origin master
On this page: https://devcenter.heroku.com/articles/getting-started-with-nodejs#prepare-the-app
It is suggested to run the command:
git clone https://github.com/heroku/node-js-getting-started.git
But if one has to clone a repository, then it seems really tedious. Because each time there are changes to the remote repository, one will have to clone the remote repository, and push it to heroku.
Did I misunderstand what the instructions are saying ? Then under "Push local changes" it says to do:
git push heroku master
This should push the local changes to heroku, under the master branch. But does that mean to push to my remote repository on bitbucket I just need to do:
git push -u origin master ?
So that way I can push to both heroku and bitbucket using just these two commands ? Is it that simple ?
Upvotes: 1
Views: 753
Reputation: 1125
As for the command git clone https://github.com/heroku/node-js-getting-started.git
, you only need to run it once per computer: at the beginning.
This clone command just means that github makes a new, local repository on your computer based on the remote repository https://github.com/heroku/node-js-getting-started.git
.
Upvotes: 2
Reputation: 2463
Yes, as git is a distributed system, you can push your changes to multiple 'remotes'. With git push -u origin master
, origin
is the name of the remote which is typically used to mean the 'main' or 'central' repo, but in reality, 'origin' is just a named remote. When using Heroku, the naming convention is to call the Heroku remote server heroku
. You can see the details of your remotes with git remote -v
. The Heroku CLI usually sets up this remote, but you can add any remotes you want with git remote add NAME URL
.
In a normal setup, you should use origin
to point to your 'main' git repo on bitbucket, to push and pull your code to whilst making changes, as well any branches and tags you're using. When you want to deploy a new release to Heroku, you should ensure your master branch is ready, and then push that to Heroku with git push heroku master
(which will trigger the build process). You should only ever use the Heroku git server to push to, it's not designed to store your code for you to later pull from.
Upvotes: 1