I have several repositories and only one has been deployed to heroku. How do I find out which one? Because I made a change in one repo and tried to push it but got a warning fatal: 'heroku' does not appear to be a git repository. Is there a command?
It looks like you have not created heroku repository yet or you are in wrong directory. Go to the directory where you have your app then create heroku with the help of below commands.
git init
heroku create
after creating heroku you can add and commit heroku with the help of
git add .
git commit -am "any comment"
last step will be to push all your data to heroku server by
git heroku push master
If repository is already created, you can check associated repository by hitting below command
$ git remote -v
You may need to run heroku git:remote command to associate a Git repository with an existing application
for more information on how to deploy app click here
Related
I created a website that I deployed on heroku. I have made some changes there and am looking to update my website to reflect these changes. To do this, I ran the following commands:
git status
git init
git status
git remote -v
git add .
git commit -m"The file"
git push heroku masterbranch
I want to clarify that the masterbranch branch is a branch that has been created. The base branch of my website is master not masterbranch. The reason why, I created a new branch is that when I ran the command: git push heroku master I was getting the error:error: failed to push some refs to 'https://git.heroku.com/gkwhelps.git' But I don't think that is the reason why my deployed site does not is not up to date.
This has nothing to do with Git itself. See the heroku documentation, which notes that:
Heroku only deploys code that you push to the master or main branches of the remote. Pushing code to another branch of the heroku remote has no effect.
You mention:
when I ran the command: git push heroku master I was getting the error: error: failed to push some refs to 'https://git.heroku.com/gkwhelps.git'
When you push to the main or master branch, Heroku will:
read your code;
attempt to build your code based on what it read in step 1;
attempt to deploy your build from step 3.
Any of these three steps can have errors. If they do have errors, Heroku uses Git to relay these errors to you and then tells Git to produce the above error message. So Git says that your push failed, but that's because Heroku told Git to fail it. You cannot fix this problem by creating another branch. You must address the problems that occurred in steps 1, 2, and/or 3.
If you first push your code on Github and from Github do deploy, you shoud do:
git status
git add .
git commit -m 'changes'
git push
After that you should connect Heroku with Github and do deploy from that branch from Github.
When I try to push my app to Heroku I get this response:
fatal: 'heroku' does not appear to be a git repository
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
You should:
Install heroku CLI plugin
Sign in using command heroku login
Add heroku as remote repository (gheroku git:remote -a YOUR_PROJECT_NAME)
Than you can push
You can find instructions here https://devcenter.heroku.com/articles/git
The issue was caused due to your project name used by another developer on heroku remote server. However, you need to change your project name and use the new name to create empty git repository on heroku server by following the command below before you push your project.
For instance, assumed you have changed your project name and is called foodproject-v2-app-launch
Note that your project name must not more than 30 characters on heroku server and must not be capitalize including special symbol except - and numbers.
Now, go to your terminal and 'cd in' to your project directory then run the below code.
Code 1: $ git init
Code 2: $ git add .
Code 3: $ git commit -m "Your Initial or Second commit"
Code 4: $ heroku create
Code 5: $ touch Procfile
Now open your Procfile with editor and add the following code and save it.
Code: web: node app.js
Code 6: $ git push heroku master
or
Code 6.1: $ git push heroku main
That should solve the issue mentioned above. Or refer to this article to read more https://devcenter.heroku.com/articles/git
I created an application on Heroku. The application is pushed to my git#heroku.com:[My-project-name].git.
I would like to push this application to my own Github account. How can I do it?
By the way, doing:
git clone git#heroku.com:[My-project-name].git
gives back:
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
If you're already signed in to Heroku account. Use the following command instead to clone an existing app to your local machine:
heroku git:clone -a your_app_name
cd your_app_name
This will clone your app on your current working directory, and then navigate to your_app_name. Then you can add your github repo's remote by:
git remote add origin url_to_your_github_repo
And finally run the following command to push the code to github:
git push origin master
I clone my repo down and change something and commit,
but when I want to push like the tutorial:
git push heroku master
it tell me wrong:
fatal: 'heroku' does not appear to be a git repository
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
I'm sure I have log in,
so how can I push my repo correctly and deploy it?
From Git Reference (http://gitref.org/remotes/#remote):
"So that you don't have to use the full URL of a remote repository every time you want to synchronize with it, Git stores an alias or nickname for each remote repository URL you are interested in. You use the git remote command to manage this list of remote repos that you care about."
You can check if remote named "heroku" exists for your git repo using:
git remote -v
If it doesn't exist, you need to add it before you can push updates as follows:
git remote add heroku git#heroku.com:appname.git
where appname should be the name of your app.
With an app in heroku, with git url like git#heroku.com:app.git,
And a repo in github https://github.com/username/other_app.git
Is possible sync the two repos for hosting the sema app in two git servers (heroku and github) ?
And also Link Heroku app to Github repo. For what?
Yes of course this is possible, because git is a distributed repository. You can configure multiple remotes, one at GitHub and one at heroku, and just push your changes to both of them.
Example:
Create repository at GitHub
Clone this repository on your machine, now you have setup the remote "origin" to be GitHub
Setup heroku and add the heroku git remote (either by running heroku create or heroku git:remote -a my_heroku_app). Find details in the git documentation of heroku.
here are some useful commands when working with github/heroku:
show github remote:
git remote show origin
show heroku git:
git remote show heroku
push github to heroku:
git push heroku master
if you have a 'staging' branch on github and want to push this to heroku git (master) for a
'staging app':
git push heroku staging:master -v