DWD Cheat Sheet
Local Development
Your code directory
- Each web application you make should have its own directory.
- The directory allows you to organize your code file and assets.
- We will use Git for version control and deploying code to Heroku.
Navigating to the code directory
- Open Terminal
Use the cd (change directory) command to navigate into the directory
cd ~/Desktop/myapp
List the files inside the directory
ls -la
Setting up Git on Code Directory
When inside the directory, you can create a Git repository. This only needs to happen once.
git init
Create a .gitignore file so Git does not track certain files and folders.
.env node_modules
Save the file as .gitignore
Add files for tracking
git add .
Commit the changes
git commit -am "init commit"
Commit when you have something worth saving
You will need to commit your changes to Git when you have made some good progress. You will need to commit before you deploy to Heroku.
git commit -am "add a commit message here detailing the changed code."
Deploying to Heroku
Create an App
Each web app can have its own Heroku app. Creating an app is easy if you have the Heroku Toolbelt installed, https://toolbelt.heroku.com.
Before you create a Heroku app,
- Have created a Git repository on the current code directory.
- Downloaded and installed the Heroku Toolbelt, https://toolbelt.heroku.com.
In Terminal, in your code directory run the following command to create a new app on Heroku.
NOTE: You only need to run heroku create once per app.
heroku create
This will create a new Git remote path that will let you push your Git repo to Heroku. You can see your remote Git paths,
git remote -v
Deploy your app to Heroku
Before you push your code to Heroku you need to commit any changes you've made since your last push.
git commit -am "made some great changes"
git push heroku master
The last command will take a few seconds as it pushes your changes to Heroku and reinstalls the web app dependencies.