joplin-notes/Export-9fad9947-5bd5-4195-952b-6512c5a4beb1/Web development 83dd4e6675f04ba782a6865a434a0598/Heroku 531d47e94b8843d7a0dc8ffce482bf9e/Installation and Pushing Code d782fb23e4a642358c74.md
2026-11-04 00:33:23 +05:30

59 lines
No EOL
950 B
Markdown

# Installation and Pushing Code
## I**nstallation**
- At root directory of nodejs app
```bash
git init
git add .
git commit -m 'initialize'
```
• (Make sure to install heroku cli)
`• heroku create or heroku create appname`
- If there is already an existing app then we need to change the prev origin to current one by:
`heroku git:remote -a appname`
- For changing app name, remote name has to be changed too.
```bash
git remote rename heroku newname
```
or
```bash
git remote heroku newname
heroku git:remote -a newname
```
- For changing app name(this has to be done before)
`heroku apps: rename newname`
or for outside git repository
`heroku apps: rename newname —app oldname`
## **Pushing Code**
`git push heroku main`
For non-main branch:
`git push heroku testbranch:main`
**In nodejs app:**
```jsx
app.listen(process.env.PORT || 3000,()=>{
console.log('listening');
})
```