I referenced this awesome thread from the following to fork my Heroku app and clone the github repo to have two seperate github repo's and Heroku app's for production and development.
Trying to heroku git:clone after heroku fork yields an empty repository
$ git clone git#heroku.com:oldapp.git -o old newclonedapp
$ cd newclonedapp
$ heroku git:remote -a newclonedapp
$ git push heroku master
I then manually moved my folder newcloneapp into its own directory. Regardless, I still get the following errors:
! Multiple apps in folder and no app specified.
! Specify app with --app APP.
How can I fix this ?
As the error message says, include --app newcloneapp in the command you are running to ensure it works with the right heroku application.
By copying the newcloneapp folder into its own directory, you are still retaining the git config for the application; hence the multiple heroku apps in this folder.
You can remove one of the applications by editing the .git/config file and removing one section with the url = git#heroku.com:your-app-name.git line.
In one of my heroku apps, I have the following config in the .git/config file:
[remote "staging"]
url = git#heroku.com:my-app-name.git
fetch = +refs/heads/*:refs/remotes/staging/*
[remote "production"]
url = git#heroku.com:my-app-name.git
fetch = +refs/heads/*:refs/remotes/staging/*
With this in place, I can push to both staging and production from the same repo. Looks like you need only one app in the folder; so you should have only one of the above sections.
Related
When I first ran my rails generator it created a folder inside of the folder I wanted to have my repository work from. What I mean by this is my github folder structure looks like this:
https://github.com/milosbunijevac/medRails
the medtools folder has the entire project, but the initial repository was started one level above the medtools folder as the repository above shows.
When I run the following commands:
heroku create
heroku buildpacks:add --index 1 heroku/nodejs
heroku buildpacks:add --index 2 heroku/ruby
and then git push heroku master from the root directory (one level above medtools) I get an error saying that app not compatible with buildpack and that the push was rejected. I'm thinking it has something to do with this strange folder structure. Do you guys and gals have any insights as to how I might fix this issue and get my project to deploy to heroku?
You could locally move everything one level up, and push back to GitHub, done in a bash session:
cd /path/to/repo
git mv medtools/* .
git rm medtools
git add .
git commit -m "move medtools content"
git push
As the OP Milos comments below, you might have to tweak the .gitignore content.
I am a Git/Heroku Newbie and I've lost files from a Rails app which I've also deployed to Heroku. Is it possible to recover the source files from Heroku?
I've found this link which says:
To clone the source of an existing application from Heroku using Git, use the heroku git:clone command:
heroku git:clone -a myapp
Replace myapp with the name of your app.
This will create a new directory named after your app with its source and complete repository history, as well as adding a heroku git remote to facilitate further updates.
I've done this but I don't know where this "new directory" is?
Thank you!
(And of course, next time I should use something like Github).
It was actually possible to copy all of the app's source files from Heroku to my local disk. When typing:
heroku git:clone -a myherokuapp
in my rails app folder (e.g. myapp) the new directory can be found at /myapp/myherokuapp/.
A little while ago the files on my Macbook Pro were deleted by Apple, including a directory from which I used to access Heroku and be able to do command line operations in the Ruby/Rails console. Now that the directory is gone, I'm not sure if it's possible to access this repository from the command line, which I need to do to reduce the size of my database to stay within Heroku limits.
Update
before the directory was deleted on my mac, I used to simply cd into that directory and then run something like bundle exec heroku run console or heroku run bundle exec console, anyways if I did it from that directory heroku knew which application i was trying to access and it would take me into the rails console for it (where I could manipulate data)
Install the Heroku toolbelt (it's unclear whether you still have that)
From the terminal, perform a heroku login to authenticate
From a directory where you want the new app to live, run heroku git:clone APP-NAME
You'll now have a directory, which will have the latest files you pushed to Heroku - which will allow you to do things like git push heroku master, or heroku run rails console.
You probably want to then also attach your git repo where you are storing your source code with something like git remote add origin git#github.com:whoyouare/app-name.git
From the Heroku docs:
You can also take an existing Git repo and add a remote using the git URL provided when you created your app. You may need to do this to associate a Git repo with an existing application. The heroku git:remote command will add this remote for you based on your applications git url.
$ heroku git:remote -a falling-wind-1624
This will add your Heroku repo with the remote name of heroku to your working directory.
I've configured the keys to my heroku, and I've gotten far enough to be able to commit and push onto my heroku server. But for some reason, commands like "heroku logs" or "heroku rake" or "heroku restart" bring up "no such file or directory" errors. Similarly, heroku restart -app "" bring up an "app not found!" even though I'd typed everything correctly.
I think this may have to do with my Github repo being stored and written on an external hard drive. Is this possible?
Thanks in advance!
An external hard drive will have nothing to do with this problem.
Make sure you are in your app.
cd myap
Then you need to create a repo and add your project to it:
git init
git add.
git commit -m 'master'
Then you need to create a heroku project:
heroku create
heroku rename myapp
git push heroku master
Make sure you have done all of that in that order.
Are you sure you are in the project folder that your application lives in. It doesn't matter where the project is as git and the project git config (including remotes) will all be local to the project folder iteself.
Also, you don't actually need to be in the project folder if you explicitly pass the application name,
eg;
heroku rake db:migrate --app myappnamehere
This also arises if you don't have your heroku remote not named heroku. Eg, I typically call my heroku remotes based off the environment eg, production, development. So my typical push looks like;
git push production mybranch:master
In this scenario when you issue a heroku command it is unable to locate the application name which is does by inspecting the git config for a 'heroku' remote so it will always say application not specified which is why you then need to pass it in explicitly via --app attribute.
I cloned a project from github over to my desktop. I used to work on it form my laptop.
However, on laptop heroku does not seem to work for this app eventhough i have it installed.
First problem:
heroku open
>No app specified.
>Run this command from app folder or set it adding --app <app name>
I did not have to specify the --app on my laptop. Because I guess I did command heroku create initially on the lapop.
Second Probelm:
git push heroku master
gives errors
fatal: 'heroku' does not appear to be a git repository
fatal: The remote end hung up unexpectedly
and heroku list
says
! This version of the heroku gem has been deprecated.
! Please update it by running: gem update heroku
First do:
git remote add heroku git#heroku.com:{my-project-name}.git
Where you replace {my-project-name} with the name of the Heroku application as it appears in your Heroku account. For example, if your Heroku account says you have an application named flowing-water-397, then the line would be:
git remote add heroku git#heroku.com:flowing-water-397.git
Then Git and the Heroku gem will know that this Git repo is connected to a Heroku.com application. Then you can do things such as:
git push heroku master
heroku open
Finally, learn a little bit more about Git Remotes.
In addition to the git remote add ... that #Justice mentioned, I also needed to run
git config heroku.remote heroku
(solution found here)
I believe I get the error No app specified. Run this command from an app folder or specify which app to use with --app when I run any ambiguous heroku commands. Example:
heroku logs
It's ambiguous because I have multiple remote repositories specified in my project's .git/config file. The solution for me is simply to specify the remote repository. Example:
heroku logs --remote staging
In the above line --remote staging corresponds to the following in my project's .git/config file:
[remote "staging"]
url = git#heroku.accountname:foo-bar-1234.git
fetch = +refs/heads/*:refs/remotes/staging/*
I hope this helps you.. if not, then perhaps it may help someone else!
When I had this issue it was because I created more than one remote app on heroku.
To remove an existing remote app from heroku use:
git remote rm heroku
then go back and use heroku create to start the process over using the correct app name heroku gives you.
Solution found here:
solution