i'm new to git and heroku.
I've created an app on heroku, pushed some files to the repo.
Now I want fully replace this app's repo with new content from another folder (and have a .git repo in that folder). What is the right way to do this?
You can change a Git remote URL using the git remote set-url command. Navigate to the repository whose remote URL you want to change and then execute this command. The set-url command accepts two arguments: the remote name and the new repository URL.
To deploy your app to Heroku, use the git push command to push the code from your local repository's main branch to your heroku remote. For example: $ git push heroku main Initializing repository, done.
If you want to completely replace the history of the commits you already pushed by the history of that new second repo, all you should need to do would be:
git remote show heroku in the first repo cd /path/to/seconf/git/repo git remote add heroku <heroku_repo_address_from_previous_command> # for instance: git remote add heroku [email protected]:appname.git git push --force heroku master
That would replace the master
branch of the remote heroku
repo by the master
branch of your second repo. But that would loose (or at least keep in reflogs of the remote repo for a while) the history of the master
branch of the former repo.
This assume you can reuse your heroku credentials you already created, following the Heroku quick start page and the Heroku Deploying with git page.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With