Deploy Rails App to Heroku(Part 2)
In this section we’ll initialize our git repository locally & will connect it to Github.
In root directory of your application run this command
This will initialize empty git repository.
Now run git status command in your terminal
It will look like this
The best part it‘s telling you what to do next. It says use
git add <file name>
to add all untracked files but if you use above method you can add files one by one like
git add db
git add config
What if you want to add all file in oneshot you can do that use
git add .
Above command will add all the untracked file. Run git status again after running git add command
It will look like below
Run git commit command to save it to your local also you have to write a message also inside the quotes to state what you have done in this commit
git commit -m "Created rails app"
It will look like
Now if you run git status
Now go to you github account then go to repositories section & click on new .Fill the information whatever it is asking for like repository name & so on. Here is mine
Then it will look something like this
Click on clone or download once
This url is to add this remote repository to your local so that you can push your changes. If you use https every time you are pushing something you have to enter your email and password else you can clone ssh url, then you don’t need to enter your email and password everytime. I’ll use ssh one
Copy that url & in your terminal use git add remote origin command to add that remote repository.
git remote add origin firstname.lastname@example.org:MeTushar/rails_heroku_deploy.git
You have to use git push origin master to push your code to master branch on github repo you created .
git push origin master
Now go to your repository on github & refresh on you’ll get something like this
So congrats finally you have pushed your code to github. In the next section will see how to use heroku to deploy code that we have on github repository.
Happy coding :)
In case if you haven’t read first part here is the link
Deploy Rails App to Heroku(Part 1) here