I have cloned sample project from Heroku
You have cloned a sample project from GitHub. You won't have permission to push to that repository, but if you did, you'd be pushing to GitHub, not to Heroku.
Now I want to link my existing GitHub repository (i.e.: https://github.com/user/my-repo
) with the cloned project.
Assuming that repository is empty, simply change the URL your remote points to:
git remote set-url origin https://github.com/user/my-repo.git
Now your origin
remote points to your own repository.
My main goal is, if I push anything to GitHub, I want the changes to be happened in both places, the Heroku repository as well as my repository (i.e: https://github.com/user/my-repo
).
Normally, you'd be able to enable GitHub integration and configure pushes to your GitHub main
branch to trigger a build on Heroku, but that feature is currently disabled while Heroku investigates a security breach.
Until that gets resolved I suggest you add a second remote:
- Install the Heroku CLI
- Log into Heroku with
heroku login
- Add a remote with
heroku git:remote -a YOUR_APP
Then verify that you can push to both remotes individually:
git push origin main
git push heroku main
You can continue to deploy that way, and I suggest you do.
But if you really want to, you can add your Heroku push URL to your origin
remote so git push origin main
actually pushes to GitHub and Heroku. Heroku outputs useful build information when you push to it and I'm not sure how well the two outputs will be kept separate if you do this.