Nicolas Raoul
Nicolas Raoul

Reputation: 60213

heroku fork + heroku git:clone = New app works but empty repository

I have a Heroku Rails app called app1 which has source code, and works.
I wanted to create a new app inspired from it but different, with different code and URL so I ran:

$ heroku fork --from app1 --to app2
$ [...]
$ Fork complete. View it at https://app1.herokuapp.com/

I checked at that URL: The cloned app works correctly.
Now let's clone it to my local computer so that I can modify it:

$ heroku git:clone -a app2
Cloning into 'app2'...
warning: You appear to have cloned an empty repository.
Checking connectivity... done.
$ cd app2/
$ ls

PROBLEM: Nothing in this folder. The repository is empty!
How is this even possible? Is the app working without code?
Do I have the wrong command for creating a local copy of the code?

Upvotes: 2

Views: 3164

Answers (2)

Nicolas Raoul
Nicolas Raoul

Reputation: 60213

Jon's answer explains why the repository is empty.
Here is how to fix the "problem":

$ cat app1/.git/config

Take note of the value of url in the paragraph origin.
It will probably look like [email protected]:app1.git.
Then run:

$ cd app2
$ git pull [email protected]:app1.git
$ git push

This will retrieve the source code (ignore the Your branch is based on 'heroku/master', but the upstream is gone. message) and replace the cloned slug with one built from this very source code.

Upvotes: 5

Jon Mountjoy
Jon Mountjoy

Reputation: 4526

Yes, see the documentation that states that the Git repo will be empty.

The app is working because it has the same slug.

In general, I advise not to think of Heroku as a source code repo - but rather put that in another place (like GitHub, say).

Upvotes: 5

Related Questions