Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git push vs. git push heroku master

I just moved from a pc laptop to a Mac, and I've noticed a curious difference in how my git commands respond.

Before, I would do the following:

git add .
git commit -m "These are my new changes"
git push # This would update my repo on github
{enter password}
git push heroku master # This would push to my app on heroku
{enter password}

Now, when I do git push, the app just deploys on Heroku without pushing to my Github repo.

How can I ensure I'm updating both places?

Edit

Thanks for your two answers! I appreciate the clarification of the difference between git push and git push heroku master, in that git push is pushing towards origin, which in my case, it seems, is Heroku.

How can I change the settings so that they work as before? i.e. I want git push to now push to my repo on Github, and I want git push heroku master to push to Heroku. The former currently pushes straight to Heroku, bypassing Github completely.

like image 699
sscirrus Avatar asked Dec 10 '10 22:12

sscirrus


People also ask

What is git push Heroku master?

To deploy your app to Heroku, use the git push command to push the code from your local repository's main branch to your heroku remote. For example: $ git push heroku main Initializing repository, done.

What is the difference between git push and git push origin master?

Git Push Origin vs Git Push Origin MasterGit Push Origin pushes all the branches to the main branch. Git Push Origin Master pushes your master branch to the origin. Behavior could be changed via git config.

What is the difference between git push and git push?

Git push origin is usually used only where there are multiple remote repositories and you want to specify which remote repository should be used for the push. For a git push origin command: git push command updates remote references using local references by sending objects necessary to complete the given references.

Does git push push to master?

Hi, To push to your remote repository without any special branch and default, it will be pushed to master branch. The git push origin command is used for pushing to the remote repository with the specific branch name.


2 Answers

To get the behavior you want, you'll need to remove the existing remotes and re-add them:

git remote show origin # copy down the heroku URL
git remote rm origin
git remote add origin [github URL]
git remote add heroku [heroku URL]
like image 65
Ben Scofield Avatar answered Nov 10 '22 11:11

Ben Scofield


Just using the command git push--that is, omitting the arguments--means that git is going to have to use the defaults, which would be your first remote repository (commonly named 'origin') as the destination, and your local master branch as the source. In your case, I'm guessing that you cloned the project from GitHub in the first place, which makes your default remote be GitHub.

When you specify the arguments git push heroku master, you are explicitly saying to push your local master branch to the remote named heroku -- thus, GitHub is not updated with this command.

(Perhaps heroku was your first/default remote on the PC, and when you moved to the Mac the origin remote was the clone from GitHub?)

like image 29
ewall Avatar answered Nov 10 '22 11:11

ewall