Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Replace remote git repo (Heroku)

Tags:

git

heroku

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?

like image 729
WHITECOLOR Avatar asked Nov 25 '11 06:11

WHITECOLOR


People also ask

How do I change a remote repository in Git?

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.

How do I deploy heroku with an existing Git repository?

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.


1 Answers

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.

like image 147
VonC Avatar answered Oct 14 '22 18:10

VonC