paint-brush
3 Easy Steps to Change Main Git Branch on Herokuby@MichaelB
1,532 reads
1,532 reads

3 Easy Steps to Change Main Git Branch on Heroku

by Michael1mAugust 20th, 2020
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

Heroku created the ability to push a Git repos from master to main instead of master. The move was easy and fast, and no more master branches in my Git repo or Heroku builds. Have any questions? Let me know in the comments below! You can deploy from main using git push heroku main or push master from main to main to deploy your app from Heroku's main repository or use the latest version of your app to test your app's ability to use Heroku build.

Company Mentioned

Mention Thumbnail
featured image - 3 Easy Steps to Change Main Git Branch on Heroku
Michael HackerNoon profile picture

I just saw that Heroku created the ability to

git push heroku
from main instead of master. Since I've been wanting to change my Git repos away from master anyway, I thought I'd check it out myself. Luckily, it was extremely simple.

(For a little background info on the issue of master vs main in Git, see here)

I followed these 3 steps:

1. First I had to move my master branch to main using

git checkout -b main
:

2. Then I had to delete the old master branch using

git branch -D master
:

3. And now I can deploy from main using

git push heroku main
.

(Heroku builds and runs the pushed code as the latest version of your app)

That's it. Easy and fast, and no more master branches in my Git repo or Heroku builds. Have any questions? Let me know in the comments below!