dani herrera
dani herrera

Reputation: 51695

"github" and "git heroku" easy way to keep both

Until now I used svn as source control. At this time I have started a new project and it is stored on gitHub.

Issue is that Heroku and GitHub, both use git. First one to publish app and second one for version control.

My app schema is:

base-dir                                    <--github base
    some-text-files (Readme, ... )
    django-project-dir                      <--heroku base
        manage.py
        main-app-dir
           settings.py
        other-app-dirs
           views.py
           models.py

When I push to gitHub base-dir and all subfolders are pushed.

To Heroku only django-project-dir should be pushed.

Notice: I have tried to create a new git repository at django-project-dir level but git take it as a submodule and excluded from gitHub.

Because this is a new project I can easily change to another schema dirs.

My question:

What is the easy way to coexist both Heroku and GitHub git configurations?

Upvotes: 1

Views: 238

Answers (3)

Michael Durrant
Michael Durrant

Reputation: 96504

You should have two remotes.

This is good and even desirable.

You have github and that's your remote code repository of record.

Then you have a current deployment via heroku and that is the 2nd remote.

Heroku is actually set up to use git as part of the system of pushing changes to your site on it.

Upvotes: 0

Michael Mior
Michael Mior

Reputation: 28752

Your best bet is to move you readme and other files to your project root. Then just add GitHub as a separate remote (when you're in your project directory).

git remote add origin https://github.com/USERNAME/REPO

Then you can push to GitHub with git push origin master. You will have to do a forced push (the -f option) the first time assuming you're pushing what used to be the repo you used exclusively for Heroku.

You'll still be able to push to Heroku with git push heroku master.

Upvotes: 1

Kevin Sylvestre
Kevin Sylvestre

Reputation: 38032

Your best option is probably to push the full repository to Heroku, but make sure Heroku ignores all files not required to run your application (see https://devcenter.heroku.com/articles/slug-compiler). Alternatively, consider creating two repositories (one for documentation and one for production code).

Upvotes: 3

Related Questions